* [PATCH v3 0/2] iio: health: max30100: Add DT LED pulse-width support
@ 2025-10-12 17:30 Shrikant Raskar
2025-10-12 17:30 ` [PATCH v3 1/2] dt-bindings: iio: health: max30100: Add LED pulse-width property Shrikant Raskar
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Shrikant Raskar @ 2025-10-12 17:30 UTC (permalink / raw)
To: jic23, robh, krzk+dt, conor+dt
Cc: dlechner, nuno.sa, andy, matt, skhan, david.hunter.linux,
linux-iio, devicetree, linux-kernel, linux-kernel-mentees,
Shrikant Raskar
Add Device Tree support for configuring the LED pulse-width of the MAX30100
sensor, and updates the driver to read and apply this property.
Testing:
- Verify DT property read successfully in probe().
- Verify default fallback to 1600 us when DT property is omitted.
- Confirm SPO2_CONFIG register programmed correctly using regmap_read().
- Validate different DT pulse-width values (200, 400, 800, 1600 us)
are applied correctly.
- Validate probe() failure for invalid LED pulse-width
- Tested-on: Raspberry Pi 3B + MAX30100 breakout board
Changelog:
Changes from v2:
- Fix DT binding schema errors
- Add default value
- Remove changelog from commit message
- Add missing header file
Shrikant Raskar (2):
dt-bindings: iio: health: max30100: Add LED pulse-width property
iio: health: max30100: Make LED pulse-width configurable via DT
.../bindings/iio/health/maxim,max30100.yaml | 8 ++++
drivers/iio/health/max30100.c | 38 +++++++++++++++++--
2 files changed, 43 insertions(+), 3 deletions(-)
base-commit: 8bd9238e511d02831022ff0270865c54ccc482d6
--
2.43.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v3 1/2] dt-bindings: iio: health: max30100: Add LED pulse-width property
2025-10-12 17:30 [PATCH v3 0/2] iio: health: max30100: Add DT LED pulse-width support Shrikant Raskar
@ 2025-10-12 17:30 ` Shrikant Raskar
2025-10-13 0:06 ` Krzysztof Kozlowski
2025-10-12 17:30 ` [PATCH v3 2/2] iio: health: max30100: Make LED pulse-width configurable via DT Shrikant Raskar
2025-10-18 15:04 ` [PATCH v3 0/2] iio: health: max30100: Add DT LED pulse-width support Jonathan Cameron
2 siblings, 1 reply; 6+ messages in thread
From: Shrikant Raskar @ 2025-10-12 17:30 UTC (permalink / raw)
To: jic23, robh, krzk+dt, conor+dt
Cc: dlechner, nuno.sa, andy, matt, skhan, david.hunter.linux,
linux-iio, devicetree, linux-kernel, linux-kernel-mentees,
Shrikant Raskar
The LED pulse width on the MAX30100 sensor determines how long the
IR/Red LEDs are driven during each sample, directly affecting the
emitted optical energy and hence the received signal amplitude.
This parameter is highly dependent on the mechanical and optical
integration of the sensor, such as:
- The type and thickness of the optical window or lens covering
the sensor.
- The distance between the LED and photodiode.
- The reflectivity of the target surface.
For example:
- A smartwatch or wearable ring with a thin glass window can operate
with shorter pulses (200-400 us) to save power.
- A medical-grade pulse oximeter or sensor mounted behind a thicker
protective layer may require longer pulses (800-1600 us) for
reliable signal amplitude.
Because this configuration is determined by hardware design rather than
by runtime conditions, it is appropriate to describe it in the DT.
If not specified, the driver defaults to 1600 us to maintain
existing behavior.
Tested on: Raspberry Pi 3B + MAX30100 breakout board.
Signed-off-by: Shrikant Raskar <raskar.shree97@gmail.com>
---
Changelog:
Changes since v2:
- Fix DT binding schema for maxim,pulse-width-us
- Remove maxItems
- Update description with additional details
- Add default value to specify fallback pulse width when property is omitted
- Remove redundant changelog from commit message
Link to v2:
https://lore.kernel.org/all/20251008031737.7321-2-raskar.shree97@gmail.com/
---
.../devicetree/bindings/iio/health/maxim,max30100.yaml | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/Documentation/devicetree/bindings/iio/health/maxim,max30100.yaml b/Documentation/devicetree/bindings/iio/health/maxim,max30100.yaml
index 967778fb0ce8..d4753c85ecc3 100644
--- a/Documentation/devicetree/bindings/iio/health/maxim,max30100.yaml
+++ b/Documentation/devicetree/bindings/iio/health/maxim,max30100.yaml
@@ -27,6 +27,14 @@ properties:
LED current whilst the engine is running. First indexed value is
the configuration for the RED LED, and second value is for the IR LED.
+ maxim,pulse-width-us:
+ description: |
+ LED pulse width in microseconds. Appropriate pulse width depends on
+ factors such as optical window absorption, LED-to-sensor distance,
+ and expected reflectivity of the skin or contact surface.
+ enum: [200, 400, 800, 1600]
+ default: 1600
+
additionalProperties: false
required:
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v3 2/2] iio: health: max30100: Make LED pulse-width configurable via DT
2025-10-12 17:30 [PATCH v3 0/2] iio: health: max30100: Add DT LED pulse-width support Shrikant Raskar
2025-10-12 17:30 ` [PATCH v3 1/2] dt-bindings: iio: health: max30100: Add LED pulse-width property Shrikant Raskar
@ 2025-10-12 17:30 ` Shrikant Raskar
2025-10-18 15:04 ` [PATCH v3 0/2] iio: health: max30100: Add DT LED pulse-width support Jonathan Cameron
2 siblings, 0 replies; 6+ messages in thread
From: Shrikant Raskar @ 2025-10-12 17:30 UTC (permalink / raw)
To: jic23, robh, krzk+dt, conor+dt
Cc: dlechner, nuno.sa, andy, matt, skhan, david.hunter.linux,
linux-iio, devicetree, linux-kernel, linux-kernel-mentees,
Shrikant Raskar
The required LED pulse width depends on board-specific optical and
mechanical design, which affects measurement accuracy and power use.
Making it configurable via Device Tree allows each platform to define
an appropriate value instead of relying on a hardcoded default.
If unspecified, the driver defaults to 1600 us for backward compatibility.
Tested on: Raspberry Pi 3B + MAX30100 breakout board.
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Signed-off-by: Shrikant Raskar <raskar.shree97@gmail.com>
---
Changelog:
Changes since v2:
- Reorder SPO2_CONFIG register defines by bit position (lowest to highest).
- Add missing header file for FIELD_PREP() macro.
- Add Reviewed-by tag.
Link to v2:
https://lore.kernel.org/all/20251008031737.7321-3-raskar.shree97@gmail.com/
---
drivers/iio/health/max30100.c | 38 ++++++++++++++++++++++++++++++++---
1 file changed, 35 insertions(+), 3 deletions(-)
diff --git a/drivers/iio/health/max30100.c b/drivers/iio/health/max30100.c
index 814f521e47ae..3d441013893c 100644
--- a/drivers/iio/health/max30100.c
+++ b/drivers/iio/health/max30100.c
@@ -5,7 +5,6 @@
* Copyright (C) 2015, 2018
* Author: Matt Ranostay <matt.ranostay@konsulko.com>
*
- * TODO: enable pulse length controls via device tree properties
*/
#include <linux/module.h>
@@ -18,6 +17,7 @@
#include <linux/mutex.h>
#include <linux/property.h>
#include <linux/regmap.h>
+#include <linux/bitfield.h>
#include <linux/iio/iio.h>
#include <linux/iio/buffer.h>
#include <linux/iio/kfifo_buf.h>
@@ -52,9 +52,13 @@
#define MAX30100_REG_MODE_CONFIG_PWR BIT(7)
#define MAX30100_REG_SPO2_CONFIG 0x07
+#define MAX30100_REG_SPO2_CONFIG_PW_MASK GENMASK(1, 0)
+#define MAX30100_REG_SPO2_CONFIG_200US 0x0
+#define MAX30100_REG_SPO2_CONFIG_400US 0x1
+#define MAX30100_REG_SPO2_CONFIG_800US 0x2
+#define MAX30100_REG_SPO2_CONFIG_1600US 0x3
#define MAX30100_REG_SPO2_CONFIG_100HZ BIT(2)
#define MAX30100_REG_SPO2_CONFIG_HI_RES_EN BIT(6)
-#define MAX30100_REG_SPO2_CONFIG_1600US 0x3
#define MAX30100_REG_LED_CONFIG 0x09
#define MAX30100_REG_LED_CONFIG_LED_MASK 0x0f
@@ -306,19 +310,47 @@ static int max30100_led_init(struct max30100_data *data)
MAX30100_REG_LED_CONFIG_LED_MASK, reg);
}
+static int max30100_get_pulse_width(unsigned int pwidth_us)
+{
+ switch (pwidth_us) {
+ case 200:
+ return MAX30100_REG_SPO2_CONFIG_200US;
+ case 400:
+ return MAX30100_REG_SPO2_CONFIG_400US;
+ case 800:
+ return MAX30100_REG_SPO2_CONFIG_800US;
+ case 1600:
+ return MAX30100_REG_SPO2_CONFIG_1600US;
+ default:
+ return -EINVAL;
+ }
+}
+
static int max30100_chip_init(struct max30100_data *data)
{
int ret;
+ int pulse_width;
+ /* set default LED pulse-width to 1600 us */
+ unsigned int pulse_us = 1600;
+ struct device *dev = &data->client->dev;
/* setup LED current settings */
ret = max30100_led_init(data);
if (ret)
return ret;
+ /* Read LED pulse-width-us from DT */
+ device_property_read_u32(dev, "maxim,pulse-width-us", &pulse_us);
+
+ pulse_width = max30100_get_pulse_width(pulse_us);
+ if (pulse_width < 0)
+ return dev_err_probe(dev, pulse_width, "invalid LED pulse-width %uus\n", pulse_us);
+
/* enable hi-res SPO2 readings at 100Hz */
ret = regmap_write(data->regmap, MAX30100_REG_SPO2_CONFIG,
MAX30100_REG_SPO2_CONFIG_HI_RES_EN |
- MAX30100_REG_SPO2_CONFIG_100HZ);
+ MAX30100_REG_SPO2_CONFIG_100HZ |
+ FIELD_PREP(MAX30100_REG_SPO2_CONFIG_PW_MASK, pulse_width));
if (ret)
return ret;
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v3 1/2] dt-bindings: iio: health: max30100: Add LED pulse-width property
2025-10-12 17:30 ` [PATCH v3 1/2] dt-bindings: iio: health: max30100: Add LED pulse-width property Shrikant Raskar
@ 2025-10-13 0:06 ` Krzysztof Kozlowski
0 siblings, 0 replies; 6+ messages in thread
From: Krzysztof Kozlowski @ 2025-10-13 0:06 UTC (permalink / raw)
To: Shrikant Raskar, jic23, robh, krzk+dt, conor+dt
Cc: dlechner, nuno.sa, andy, matt, skhan, david.hunter.linux,
linux-iio, devicetree, linux-kernel, linux-kernel-mentees
On 12/10/2025 19:30, Shrikant Raskar wrote:
> The LED pulse width on the MAX30100 sensor determines how long the
> IR/Red LEDs are driven during each sample, directly affecting the
> emitted optical energy and hence the received signal amplitude.
>
> This parameter is highly dependent on the mechanical and optical
> integration of the sensor, such as:
> - The type and thickness of the optical window or lens covering
> the sensor.
> - The distance between the LED and photodiode.
> - The reflectivity of the target surface.
>
> For example:
> - A smartwatch or wearable ring with a thin glass window can operate
> with shorter pulses (200-400 us) to save power.
> - A medical-grade pulse oximeter or sensor mounted behind a thicker
> protective layer may require longer pulses (800-1600 us) for
> reliable signal amplitude.
>
> Because this configuration is determined by hardware design rather than
> by runtime conditions, it is appropriate to describe it in the DT.
>
> If not specified, the driver defaults to 1600 us to maintain
> existing behavior.
>
> Tested on: Raspberry Pi 3B + MAX30100 breakout board.
>
> Signed-off-by: Shrikant Raskar <raskar.shree97@gmail.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3 0/2] iio: health: max30100: Add DT LED pulse-width support
2025-10-12 17:30 [PATCH v3 0/2] iio: health: max30100: Add DT LED pulse-width support Shrikant Raskar
2025-10-12 17:30 ` [PATCH v3 1/2] dt-bindings: iio: health: max30100: Add LED pulse-width property Shrikant Raskar
2025-10-12 17:30 ` [PATCH v3 2/2] iio: health: max30100: Make LED pulse-width configurable via DT Shrikant Raskar
@ 2025-10-18 15:04 ` Jonathan Cameron
2025-10-24 8:38 ` Shrikant
2 siblings, 1 reply; 6+ messages in thread
From: Jonathan Cameron @ 2025-10-18 15:04 UTC (permalink / raw)
To: Shrikant Raskar
Cc: robh, krzk+dt, conor+dt, dlechner, nuno.sa, andy, matt, skhan,
david.hunter.linux, linux-iio, devicetree, linux-kernel,
linux-kernel-mentees
On Sun, 12 Oct 2025 23:00:33 +0530
Shrikant Raskar <raskar.shree97@gmail.com> wrote:
> Add Device Tree support for configuring the LED pulse-width of the MAX30100
> sensor, and updates the driver to read and apply this property.
>
> Testing:
> - Verify DT property read successfully in probe().
> - Verify default fallback to 1600 us when DT property is omitted.
> - Confirm SPO2_CONFIG register programmed correctly using regmap_read().
> - Validate different DT pulse-width values (200, 400, 800, 1600 us)
> are applied correctly.
> - Validate probe() failure for invalid LED pulse-width
> - Tested-on: Raspberry Pi 3B + MAX30100 breakout board
>
> Changelog:
> Changes from v2:
> - Fix DT binding schema errors
> - Add default value
> - Remove changelog from commit message
> - Add missing header file
>
> Shrikant Raskar (2):
> dt-bindings: iio: health: max30100: Add LED pulse-width property
> iio: health: max30100: Make LED pulse-width configurable via DT
>
> .../bindings/iio/health/maxim,max30100.yaml | 8 ++++
> drivers/iio/health/max30100.c | 38 +++++++++++++++++--
> 2 files changed, 43 insertions(+), 3 deletions(-)
>
>
> base-commit: 8bd9238e511d02831022ff0270865c54ccc482d6
Applied to the togreg branch of iio.git and pushed out as testing for now
Thanks,
Jonathan
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3 0/2] iio: health: max30100: Add DT LED pulse-width support
2025-10-18 15:04 ` [PATCH v3 0/2] iio: health: max30100: Add DT LED pulse-width support Jonathan Cameron
@ 2025-10-24 8:38 ` Shrikant
0 siblings, 0 replies; 6+ messages in thread
From: Shrikant @ 2025-10-24 8:38 UTC (permalink / raw)
To: Jonathan Cameron
Cc: robh, krzk+dt, conor+dt, dlechner, nuno.sa, andy, matt, skhan,
david.hunter.linux, linux-iio, devicetree, linux-kernel,
linux-kernel-mentees
On Sat, Oct 18, 2025 at 8:34 PM Jonathan Cameron <jic23@kernel.org> wrote:
>
> On Sun, 12 Oct 2025 23:00:33 +0530
> Shrikant Raskar <raskar.shree97@gmail.com> wrote:
>
> > Add Device Tree support for configuring the LED pulse-width of the MAX30100
> > sensor, and updates the driver to read and apply this property.
> >
> > Testing:
> > - Verify DT property read successfully in probe().
> > - Verify default fallback to 1600 us when DT property is omitted.
> > - Confirm SPO2_CONFIG register programmed correctly using regmap_read().
> > - Validate different DT pulse-width values (200, 400, 800, 1600 us)
> > are applied correctly.
> > - Validate probe() failure for invalid LED pulse-width
> > - Tested-on: Raspberry Pi 3B + MAX30100 breakout board
> >
> > Changelog:
> > Changes from v2:
> > - Fix DT binding schema errors
> > - Add default value
> > - Remove changelog from commit message
> > - Add missing header file
> >
> > Shrikant Raskar (2):
> > dt-bindings: iio: health: max30100: Add LED pulse-width property
> > iio: health: max30100: Make LED pulse-width configurable via DT
> >
> > .../bindings/iio/health/maxim,max30100.yaml | 8 ++++
> > drivers/iio/health/max30100.c | 38 +++++++++++++++++--
> > 2 files changed, 43 insertions(+), 3 deletions(-)
> >
> >
> > base-commit: 8bd9238e511d02831022ff0270865c54ccc482d6
>
> Applied to the togreg branch of iio.git and pushed out as testing for now
Thanks for the update. I really appreciate your time and support!
Regards,
Shrikant
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-10-24 8:38 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-12 17:30 [PATCH v3 0/2] iio: health: max30100: Add DT LED pulse-width support Shrikant Raskar
2025-10-12 17:30 ` [PATCH v3 1/2] dt-bindings: iio: health: max30100: Add LED pulse-width property Shrikant Raskar
2025-10-13 0:06 ` Krzysztof Kozlowski
2025-10-12 17:30 ` [PATCH v3 2/2] iio: health: max30100: Make LED pulse-width configurable via DT Shrikant Raskar
2025-10-18 15:04 ` [PATCH v3 0/2] iio: health: max30100: Add DT LED pulse-width support Jonathan Cameron
2025-10-24 8:38 ` Shrikant
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).