Add support for AS7343 multi-spectral sensor
Subsystems (2)
v6 cover Add support for AS7343 multi-spectral sensor
This series adds initial support for the AMS AS7343 14-channel multi-spectral sensor.
The sensor has 14 optical channels (11 visible + NIR + clear + flicker) in total. This initial driver supports reading raw counts from all 12 spectral channels (11 visible + NIR) via sysfs and basic power management.
Not yet supported:
- Configurable integration time and gain
- Interrupt support
- Clear (VIS) channel and flicker detection
Patch 1 adds device tree bindings.
Patch 2 adds the driver.
Testing was performed on a Raspberry Pi 4.
Datasheet: https://look.ams-osram.com/m/5f2d27fff9a874d2/original/AS7343-14-Channel-Multi-Spectral-Sensor.pdf
Changes in v6:
- Add a ref to leds/common.yaml for the LDR pin in dt bindings.
- Convert ATIME and ASTEP range checks to runtime checks.
Changes in v5:
- Remove the GPIO pin from dt bindings.
- Add autosuspend.
- Start measurements before setting up runtime PM.
Changes in v4:
- Fix led-max-microamp property in dt bindings.
- Use REGCACHE_MAPLE and add volatile table.
- Use PM_RUNTIME_ACQUIRE* when resuming.
Changes in v3:
- Fix gpio description and example in dt.
- Only start measurements after suspend action has been registered.
- Add a mutex and pm_runtime_resume_and_get before reading measurements.
Changes in v2:
- Add the LDR, the interrupt pin, and the GPIO pin to the dt bindings.
- Adjust the default gain to x256 and integration time to 50.1ms as recommended by the datasheet.
- Use read_label instead of .extend
- Remove all unused scan_index related constants.
Chang Yu (2):
dt-bindings: iio: light: add as7343
iio: light: add AS7343 multi-spectral sensor driver
.../bindings/iio/light/ams,as7343.yaml | 66 +++ MAINTAINERS | 7 + drivers/iio/light/Kconfig | 11 + drivers/iio/light/Makefile | 1 + drivers/iio/light/as7343.c | 464 ++++++++++++++++++ 5 files changed, 549 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/light/ams,as7343.yaml create mode 100644 drivers/iio/light/as7343.c
Signature · 1 line
2.56.0
PATCH v6 1/2 dt-bindings: iio: light: add as7343
Add binding for AMS AS7343 which is a 14-channel multi-spectral sensor with i2c address of 0x39.
The GPIO pin is not described because the datasheet does not document how to use it for hardware synchronization at all. The GPIO register also has no mode-select bit to isolate the pin from the chip's internal control logic. Exposing it as a generic GPIO could result in kernel writes being overwritten by internal logic.
Datasheet: https://look.ams-osram.com/m/5f2d27fff9a874d2/original/AS7343-14-Channel-Multi-Spectral-Sensor.pdf
---
Changes in v6:
- Add a ref to leds/common.yaml for the LDR pin.
Changes in v5:
- Remove the GPIO pin.
Changes in v4:
- Fix led-max-microamp property name.
Changes in v3:
- Add missing include for gpio.
- Expand GPIO descrption to include hardware synchronization.
- Use led-max-microamp instead of led-current-microamp for the LDR pin.
Changes in v2:
- Add the LDR, the interrupt pin, and the GPIO pin to the bindings.
- Fix node name and unit address mismatch.
- Include MAINTAINERS changes.
.../bindings/iio/light/ams,as7343.yaml | 66 +++++++++++++++++++ MAINTAINERS | 6 ++ 2 files changed, 72 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/light/ams,as7343.yaml
Documentation/devicetree/bindings/iio/light/ams,as7343.yaml new file +66 -0
@@ -0,0 +1,66 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/light/ams,as7343.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: AMS AS7343 14-Channel Multi-Spectral Sensor + +maintainers: + - Chang Yu <[email protected]> + +description: | + The AMS AS7343 is a 14-channel multi-spectral sensor with i2c address of 0x39. + https://look.ams-osram.com/m/5f2d27fff9a874d2/original/AS7343-14-Channel-Multi-Spectral-Sensor.pdf + +properties: + compatible: + enum: + - ams,as7343 + + reg: + description: + I2C address of the device (0x39). + maxItems: 1 + + interrupts: + description: + Open drain output active low interrupt pin. + maxItems: 1 + + vdd-supply: true + + led-max-microamp: + description: + The driver current for the external LED connected to the LDR pin. + minimum: 4000 + maximum: 258000 + multipleOf: 2000 + default: 12000 + +required: + - compatible + - reg + - vdd-supply + +additionalProperties: false + +allOf: + - $ref: /schemas/leds/common.yaml# + +examples: + - | + #include <dt-bindings/interrupt-controller/irq.h> + + i2c { + #address-cells = <1>; + #size-cells = <0>; + + multispectral-sensor@39 { + compatible = "ams,as7343"; + reg = <0x39>; + interrupts = <7 IRQ_TYPE_LEVEL_LOW>; + vdd-supply = <&vdd_regulator>; + led-max-microamp = <14000>; + }; + };
MAINTAINERS +6 -0
@@ -1430,6 +1430,12 @@ S: Maintained F: Documentation/devicetree/bindings/iio/light/ams,as73211.yaml F: drivers/iio/light/as73211.c +AMS AS7343 DRIVER +M: Chang Yu <[email protected]> +L: [email protected] +S: Maintained +F: Documentation/devicetree/bindings/iio/light/ams,as7343.yaml + AMT (Automatic Multicast Tunneling) M: Taehee Yoo <[email protected]> L: [email protected]
Signature · 1 line
2.56.0
[email protected]
AI reviewRe: [PATCH v6 1/2] dt-bindings: iio: light: add as7343
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] dt-bindings: additionalProperties: false blocks referenced LED properties --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] dt-bindings: additionalProperties: false blocks referenced LED properties --
commit 91a13bd8ef095a37fbdedc3e1a205c8195e990a3
Author: Chang Yu <[email protected]>
dt-bindings: iio: light: add as7343
This commit adds a device tree binding schema for the AMS AS7343, a 14-channel multi-spectral sensor.
Quoted 5 lines
Documentation/devicetree/bindings/iio/light/ams,as7343.yaml new file +0
-0
[ ... ]
Documentation/devicetree/bindings/iio/light/ams,as7343.yaml line 49
Quoted 9 lines
Documentation/devicetree/bindings/iio/light/ams,as7343.yaml new file +9
-0+required: + - compatible + - reg + - vdd-supply + +additionalProperties: false + +allOf: + - $ref: /schemas/leds/common.yaml#
[Severity: Low]
Will additionalProperties: false cause the schema validator to incorrectly reject valid LED properties?
Because additionalProperties is set to false at the root level, only the properties explicitly listed in the local properties dictionary are allowed. When a device tree author adds standard LED properties (such as function, color, or label) included by the /schemas/leds/common.yaml reference, they will fail validation as unallowed additional properties.
Could we use unevaluatedProperties: false instead? This would allow the properties defined in the externally referenced common LED schema to pass validation correctly.
Quoted 2 lines
Documentation/devicetree/bindings/iio/light/ams,as7343.yaml new file +2
-0+ +examples:
[ ... ]
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Re: [PATCH v6 1/2] dt-bindings: iio: light: add as7343
In reply to Chang YuQuoted 78 lines · On Tue, 13 Oct 2026 19:56:38 +0800 Chang Yu <[email protected]> wrote:
Add binding for AMS AS7343 which is a 14-channel multi-spectral sensor with i2c address of
0x39.The GPIO pin is not described because the datasheet does not document how to use it for hardware synchronization at all. The GPIO register also has no mode-select bit to isolate the pin from the chip's internal control logic. Exposing it as a generic GPIO could result in kernel writes being overwritten by internal logic.
Datasheet: https://look.ams-osram.com/m/5f2d27fff9a874d2/original/AS7343-14-Channel-Multi-Spectral-Sensor.pdf
Signed-off-by Chang Yu <[email protected]>---
Changes in v6:
- Add a ref toleds/common.yamlfor the LDR pin.Changes in v5:
- Remove the GPIO pin.Changes in v4:
- Fix led-max-microamp property name.Changes in v3:
- Add missing include for gpio.
- Expand GPIO descrption to include hardware synchronization.
- Use led-max-microamp instead of led-current-microamp for the LDR pin.Changes in v2:
- Add the LDR, the interrupt pin, and the GPIO pin to the bindings.
- Fix node name and unit address mismatch.
- IncludeMAINTAINERSchanges..../bindings/iio/light/ams,as7343.yaml | 66 +++++++++++++++++++ MAINTAINERS | 6 ++ 2 files changed, 72 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/light/ams,as7343.yamlDocumentation/devicetree/bindings/iio/light/ams,as7343.yaml new file +36
-0@@ -0,0 +1,66 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/light/ams,as7343.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: AMS AS7343 14-Channel Multi-Spectral Sensor + +maintainers: + - Chang Yu <[email protected]> + +description: | + The AMS AS7343 is a 14-channel multi-spectral sensor with i2c address of 0x39. + https://look.ams-osram.com/m/5f2d27fff9a874d2/original/AS7343-14-Channel-Multi-Spectral-Sensor.pdf + +properties: + compatible: + enum: + - ams,as7343 + + reg: + description: + I2C address of the device (0x39). + maxItems: 1 + + interrupts: + description: + Open drain output active low interrupt pin. + maxItems: 1 + + vdd-supply: true + + led-max-microamp: + description: + The driver current for the external LED connected to the LDR pin. + minimum: 4000
Documentation/devicetree/bindings/iio/light/ams,as7343.yaml line 46
Quoted 10 lines
Documentation/devicetree/bindings/iio/light/ams,as7343.yaml new file +10
-0+ maximum: 258000 + multipleOf: 2000 + default: 12000 + +required: + - compatible + - reg + - vdd-supply + +additionalProperties: false
Should be unevaluatedProperties as you're using $refs in the binding, but Jonathan could tweak that when applying.
Signature · 2 lines
Kind regards, Joshua Crofts
Re: [PATCH v6 1/2] dt-bindings: iio: light: add as7343
Quoted 86 lines · Joshua Crofts
Quoted 83 lines · On Tue, 13 Oct 2026 19:56:38 +0800 Chang Yu <[email protected]> wrote:
Add binding for AMS AS7343 which is a 14-channel multi-spectral sensor with i2c address of
0x39.The GPIO pin is not described because the datasheet does not document how to use it for hardware synchronization at all. The GPIO register also has no mode-select bit to isolate the pin from the chip's internal control logic. Exposing it as a generic GPIO could result in kernel writes being overwritten by internal logic.
Datasheet: https://look.ams-osram.com/m/5f2d27fff9a874d2/original/AS7343-14-Channel-Multi-Spectral-Sensor.pdf
Signed-off-by Chang Yu <[email protected]>---
Changes in v6:
- Add a ref toleds/common.yamlfor the LDR pin.Changes in v5:
- Remove the GPIO pin.Changes in v4:
- Fix led-max-microamp property name.Changes in v3:
- Add missing include for gpio.
- Expand GPIO descrption to include hardware synchronization.
- Use led-max-microamp instead of led-current-microamp for the LDR pin.Changes in v2:
- Add the LDR, the interrupt pin, and the GPIO pin to the bindings.
- Fix node name and unit address mismatch.
- IncludeMAINTAINERSchanges..../bindings/iio/light/ams,as7343.yaml | 66 +++++++++++++++++++ MAINTAINERS | 6 ++ 2 files changed, 72 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/light/ams,as7343.yamlDocumentation/devicetree/bindings/iio/light/ams,as7343.yaml new file +41
-0@@ -0,0 +1,66 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/light/ams,as7343.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: AMS AS7343 14-Channel Multi-Spectral Sensor + +maintainers: + - Chang Yu <[email protected]> + +description: | + The AMS AS7343 is a 14-channel multi-spectral sensor with i2c address of 0x39. + https://look.ams-osram.com/m/5f2d27fff9a874d2/original/AS7343-14-Channel-Multi-Spectral-Sensor.pdf + +properties: + compatible: + enum: + - ams,as7343 + + reg: + description: + I2C address of the device (0x39). + maxItems: 1 + + interrupts: + description: + Open drain output active low interrupt pin. + maxItems: 1 + + vdd-supply: true + + led-max-microamp: + description: + The driver current for the external LED connected to the LDR pin. + minimum: 4000 + maximum: 258000 + multipleOf: 2000 + default: 12000 + +required:
Quoted 9 lines
Documentation/devicetree/bindings/iio/light/ams,as7343.yaml line 46
Quoted 5 lines
Documentation/devicetree/bindings/iio/light/ams,as7343.yaml new file +5
-0+ - compatible + - reg + - vdd-supply + +additionalProperties: falseShould be unevaluatedProperties as you're using $refs in the binding, but Jonathan could tweak that when applying.
There was a discussion about this back in v2 in which Conor was suggesting keeping additionalProperties: false if I recall. I don't know the exact pros vs cons so I'll defer to the experts here.
Re: [PATCH v6 1/2] dt-bindings: iio: light: add as7343
Quoted 6 lines · On Tue, 13 Oct 2026 23:15:21 +0800 Chang Yu <[email protected]> wrote:
Quoted 3 lines
Should be unevaluatedProperties as you're using $refs in the binding, but Jonathan could tweak that when applying.
There was a discussion about this back in v2 in which Conor was suggesting keeping additionalProperties: false if I recall. I don't know the exact pros vs cons so I'll defer to the experts here.
Fair enough, if dt maintainers say so then it's fine.
Signature · 2 lines
Kind regards, Joshua Crofts
Re: [PATCH v6 1/2] dt-bindings: iio: light: add as7343
In reply to Chang YuOn 10/13/26 1:56 PM, Chang Yu wrote:
[snip]
Documentation/devicetree/bindings/iio/light/ams,as7343.yaml line 24
Quoted 5 lines
Documentation/devicetree/bindings/iio/light/ams,as7343.yaml new file +5
-0+ + reg: + description: + I2C address of the device (0x39). + maxItems: 1
on v4 Jonathan said "Might as well specify it as const given it can only take that value. They you can drop the description as it won't add anything." v6 still has the old form, looks like that got lost.
[snip]> +
Documentation/devicetree/bindings/iio/light/ams,as7343.yaml line 35
Quoted 10 lines
Documentation/devicetree/bindings/iio/light/ams,as7343.yaml new file +10
-0+ interrupts: + description: + Open drain output active low interrupt pin. + maxItems: 1 + + vdd-supply: true + + led-max-microamp: + description: + The driver current for the external LED connected to the LDR pin.
this wording dates from when it was ams,led-current-microamp. leds/common.yaml defines led-max-microamp as a maximum ("risk of hardware damage in case an excessive current is set"), i.e. the board limit for LED_DRIVE, not the current program. please describe it as a maximum.
Signature · 2 lines
cheers, jose a. p-a
Re: [PATCH v6 1/2] dt-bindings: iio: light: add as7343
In reply to Chang YuDocumentation/devicetree/bindings/iio/light/ams,as7343.yaml line 46
Quoted 6 lines · Chang Yu
Documentation/devicetree/bindings/iio/light/ams,as7343.yaml new file +6
-0+required: + - compatible + - reg + - vdd-supply + +additionalProperties: false
This goes after allOf: block, see example schema.
Documentation/devicetree/bindings/iio/light/ams,as7343.yaml line 49
Quoted 3 lines
Documentation/devicetree/bindings/iio/light/ams,as7343.yaml new file +3
-0+ +allOf: + - $ref: /schemas/leds/common.yaml#
Best regards,
Krzysztof
PATCH v6 2/2 iio: light: add AS7343 multi-spectral sensor driver
In reply to Chang YuAdd a driver for the AMS AS7343 14-channel multi-spectral sensor.
The AS7343 is a 14-channel spectral sensor featuring 11 visible channels, 1 near-infrared channel, 1 clear channel (VIS), and 1 flicker detection channel.
The driver exposes 12 spectral channels (11 visible light and 1 near-infrared) via sysfs. Runtime PM is implemented to stop measurements when the device is suspended or torn down. Power is never cut (PON=1 always) to preserve register values.
Future patches will add configurable gain and integration time, interrupt support, buffered reads, VIS channel, and flicker detection.
Datasheet: https://look.ams-osram.com/m/5f2d27fff9a874d2/original/AS7343-14-Channel-Multi-Spectral-Sensor.pdf
---
Changes in v6:
- Convert ASTEP and ATIME range checks to runtime checks.
- Move adding suspend action to before setting autosuspend delay.
Changes in v5:
- Add autosuspend support.
- Start measurements before configuring runtime PM.
- Add functions for computing ASTEP and ATIME.
- Sort registers by addresses.
Changes in v4:
- Use REGCACHE_MAPLE and add volatile register table.
- Use PM_RUNTIME_ACQUIRE* when resuming.
- Use a static array for labels.
- Various code style fixes.
Changes in v3:
- Hold a mutex before reading measurements.
- Add pm_runtime_resume_and_get before reading measurements.
- Only start measurements after suspend action has been successfully registered
- Check the return value of regmap_read when verifying device ID.
Changes in v2:
- Adjust the default gain to x256 and integration time to 50.1ms as recommended by the datasheet.
- Use read_label instead of .extend
- Remove all unused scan_index related constants.
- Add missing calls to pm_runtime_* methods in probe.
- Fix various code style issues
MAINTAINERS | 1 + drivers/iio/light/Kconfig | 11 + drivers/iio/light/Makefile | 1 + drivers/iio/light/as7343.c | 464 +++++++++++++++++++++++++++++++++++++ 4 files changed, 477 insertions(+) create mode 100644 drivers/iio/light/as7343.c
MAINTAINERS +1 -0
@@ -1435,6 +1435,7 @@ M: Chang Yu <[email protected]> L: [email protected] S: Maintained F: Documentation/devicetree/bindings/iio/light/ams,as7343.yaml +F: drivers/iio/light/as7343.c AMT (Automatic Multicast Tunneling) M: Taehee Yoo <[email protected]>
drivers/iio/light/Kconfig +11 -0
@@ -149,6 +149,17 @@ config AS73211 This driver can also be built as a module. If so, the module will be called as73211. +config AS7343 + tristate "AMS AS7343 14-Channel Multi-Spectral Sensor" + depends on I2C + select REGMAP_I2C + help + Say Y here to build support for the AMS AS7343 14-channel + multi-spectral sensor. + + To compile this driver as a module, choose M here: the module will + be called as7343. + config BH1745 tristate "ROHM BH1745 colour sensor" depends on I2C
drivers/iio/light/Makefile +1 -0
@@ -16,6 +16,7 @@ obj-$(CONFIG_APDS9306) += apds9306.o obj-$(CONFIG_APDS9960) += apds9960.o obj-$(CONFIG_APDS9999) += apds9999.o obj-$(CONFIG_AS73211) += as73211.o +obj-$(CONFIG_AS7343) += as7343.o obj-$(CONFIG_BH1745) += bh1745.o obj-$(CONFIG_BH1750) += bh1750.o obj-$(CONFIG_BH1780) += bh1780.o
drivers/iio/light/as7343.c new file +464 -0
464 lines not on this page · raw message
Signature · 1 line
2.56.0
Re: [PATCH v6 2/2] iio: light: add AS7343 multi-spectral sensor driver
Quoted 11 lines · On Tue, 13 Oct 2026 19:56:39 +0800 Chang Yu <[email protected]> wrote:
Add a driver for the AMS AS7343 14-channel multi-spectral sensor.
The AS7343 is a 14-channel spectral sensor featuring 11 visible channels, 1 near-infrared channel, 1 clear channel (VIS), and 1 flicker detection channel.
The driver exposes 12 spectral channels (11 visible light and 1 near-infrared) via sysfs. Runtime PM is implemented to stop measurements when the device is suspended or torn down. Power is never cut (PON=1 always) to preserve register values.
Quoted 7 lines
Future patches will add configurable gain and integration time, interrupt support, buffered reads, VIS channel, and flicker detection.
Datasheet: https://look.ams-osram.com/m/5f2d27fff9a874d2/original/AS7343-14-Channel-Multi-Spectral-Sensor.pdf
Signed-off-by Chang Yu <[email protected]>---
I think this is ready to be applied.
Signature · 2 lines
Kind regards, Joshua Crofts
Andy Shevchenko
Reviewed-byRe: [PATCH v6 2/2] iio: light: add AS7343 multi-spectral sensor driver
Quoted 18 lines · Joshua Crofts
Quoted 15 lines · On Tue, 13 Oct 2026 19:56:39 +0800 Chang Yu <[email protected]> wrote:
Add a driver for the AMS AS7343 14-channel multi-spectral sensor.
The AS7343 is a 14-channel spectral sensor featuring 11 visible channels, 1 near-infrared channel, 1 clear channel (VIS), and 1 flicker detection channel.
The driver exposes 12 spectral channels (11 visible light and 1 near-infrared) via sysfs. Runtime PM is implemented to stop measurements when the device is suspended or torn down. Power is never cut (PON=1 always) to preserve register values.
Future patches will add configurable gain and integration time, interrupt support, buffered reads, VIS channel, and flicker detection.
Quoted 5 lines
Quoted 3 lines
Datasheet: https://look.ams-osram.com/m/5f2d27fff9a874d2/original/AS7343-14-Channel-Multi-Spectral-Sensor.pdf
Signed-off-by Chang Yu <[email protected]>---
I think this is ready to be applied.
I agree. I have a few nit-picks (easy to address), after that feel also free to add
Quoted 1 line
Reviewed-by Joshua Crofts <[email protected]>
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v6 2/2] iio: light: add AS7343 multi-spectral sensor driver
In reply to Chang YuQuoted 14 lines · Chang Yu
Add a driver for the AMS AS7343 14-channel multi-spectral sensor.
The AS7343 is a 14-channel spectral sensor featuring 11 visible channels, 1 near-infrared channel, 1 clear channel (VIS), and 1 flicker detection channel.
The driver exposes 12 spectral channels (11 visible light and 1 near-infrared) via sysfs. Runtime PM is implemented to stop measurements when the device is suspended or torn down. Power is never cut (PON=1 always) to preserve register values.
Future patches will add configurable gain and integration time, interrupt support, buffered reads, VIS channel, and flicker detection.
...
Quoted 4 lines
+/*
+ * Integration time is calculated as (ATIME + 1) * ((ASTEP + 1) * 2.78us).
+ * ATIME must be between 0 and 255, inclusive
+ * ASTEP must be between 0 and 65534, inclusive
Haven't noticed before, but is it indeed 65534 and not 65535 here (or 255 and not 254 above)? Haven't checked datasheet, please double check.
Quoted 1 line
+ */
...
drivers/iio/light/as7343.c line 248
Quoted 7 lines
drivers/iio/light/as7343.c new file +7
-0+static int as7343_read_label (struct iio_dev *indio_dev, +struct iio_chan_spec const *chan,char *label) +{ +int channel; + + channel = chan->channel; +if (channel <0 || channel >=ARRAY_SIZE (as7343_channel_labels))
in_range()?
Review
Quoted 1 line
(quoted diff) +1
-0+ return -EINVAL;
-ECHRNG ?
Quoted 2 lines
drivers/iio/light/as7343.c new file +2
-0+return sysfs_emit (label,"%s\n" , as7343_channel_labels[channel]); +}
...
drivers/iio/light/as7343.c line 330
Quoted 3 lines
drivers/iio/light/as7343.c new file +3
-0+/* +* Setting a 600 * 2.78us * 30 = 50ms integration time as the default +* for now.
Where magic 600 came from? Please, elaborate in the comment.
Quoted 4 lines
drivers/iio/light/as7343.c new file +4
-0+*/ + ret =as7343_astep_x2780ns (600 , &astep); +if (ret) +return ret;
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v6 2/2] iio: light: add AS7343 multi-spectral sensor driver
Quoted 18 lines · Andy Shevchenko
Quoted 14 lines · Chang Yu
Add a driver for the AMS AS7343 14-channel multi-spectral sensor.
The AS7343 is a 14-channel spectral sensor featuring 11 visible channels, 1 near-infrared channel, 1 clear channel (VIS), and 1 flicker detection channel.
The driver exposes 12 spectral channels (11 visible light and 1 near-infrared) via sysfs. Runtime PM is implemented to stop measurements when the device is suspended or torn down. Power is never cut (PON=1 always) to preserve register values.
Future patches will add configurable gain and integration time, interrupt support, buffered reads, VIS channel, and flicker detection.
...
Quoted 8 lines
Quoted 4 lines
+/*
+ * Integration time is calculated as (ATIME + 1) * ((ASTEP + 1) * 2.78us).
+ * ATIME must be between 0 and 255, inclusive
+ * ASTEP must be between 0 and 65534, inclusiveHaven't noticed before, but is it indeed 65534 and not 65535 here (or 255 and not 254 above)? Haven't checked datasheet, please double check.
Per the datasheet 0 <= ASTEP <= 65534 (65535 was explicitly marked as "do not use"), and since ASTEP = n - 1, we have 1 <= n <= 65535. Similary 0 <= ATIME <= 255, ATIME = step - 1, so 1 <= step <= 256.
So I think the numbers here are correct.
Re: [PATCH v6 2/2] iio: light: add AS7343 multi-spectral sensor driver
Quoted 2 lines · Chang Yu
Quoted 1 line · Andy Shevchenko
On Tue, Oct 13, 2026 at 07:56:39PM +0800, Chang Yu wrote:
...
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
+/*
+ * Integration time is calculated as (ATIME + 1) * ((ASTEP + 1) * 2.78us).
+ * ATIME must be between 0 and 255, inclusive
+ * ASTEP must be between 0 and 65534, inclusive
Quoted 8 lines
Quoted 3 lines
Haven't noticed before, but is it indeed 65534 and not 65535 here (or 255 and not 254 above)? Haven't checked datasheet, please double check.
Per the datasheet 0 <= ASTEP <= 65534 (65535 was explicitly marked as "do not use"), and since ASTEP = n - 1, we have 1 <= n <= 65535. Similary 0 <= ATIME <= 255, ATIME = step - 1, so 1 <= step <= 256.
So I think the numbers here are correct.
Thanks for checking! In case you need a new version, just add that into the above comment, like
* Per datasheet, do not use 65535 for ASTEP.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v6 2/2] iio: light: add AS7343 multi-spectral sensor driver
In reply to Chang YuOn 10/13/26 1:56 PM, Chang Yu wrote:
found a few things before I can give a tag, correct me if I'm wrong.
Quoted 4 lines
The driver exposes 12 spectral channels (11 visible light and 1 near-infrared) via sysfs. Runtime PM is implemented to stop measurements when the device is suspended or torn down. Power is never cut (PON=1 always) to preserve register values.
PON=0 is SLEEP, not power off. per the datasheet, entering SLEEP doesn't change register settings. idle is 40 uA vs 0.7 uA in sleep. worth clearing PON in the teardown action, and probably runtime suspend too.
if this goes in as v6, Jonathan, could you drop the "to preserve register values" part of the commit message when applying?
[snip]
Quoted 1 line
+/* AS7343 channel indices. MUST match data register order above. */
nothing depends on this. drop the MUST, just say it follows the DATA register order for auto_smux = 3.
[snip]
Quoted 1 line
+static inline int
as7343_atime_steps(unsigned int step, u8 *atime)
no inline in .c files. same for the other helper.
[snip]
drivers/iio/light/as7343.c line 182
Quoted 5 lines
drivers/iio/light/as7343.c new file +5
-0+ +switch (mask) { +case IIO_CHAN_INFO_RAW : { +/* Wait until integration time passes for all 3 cycles. */ +msleep (160 );
derive this from the ATIME/ASTEP defaults, or spell out the math.
drivers/iio/light/as7343.c line 191
Quoted 9 lines
drivers/iio/light/as7343.c new file +9
-0+ +/* +* Reading ASTATUS latches all data registers to this read. +* We don't care about the returned saturation/gain status for +* now. +*/ +guard (mutex)(&data->mutex); + + ret =regmap_read (map,AS7343_ASTATUS_REG , &unused);
ASAT_STATUS (bit 7) is thrown away, so saturated counts get returned as valid, while the datasheet says to discard them. ideally fixed before this hits a release, since changing what read_raw returns after that is user-visible. Jonathan, any preference on what it should return then?
[snip]
drivers/iio/light/as7343.c line 331
Quoted 4 lines
drivers/iio/light/as7343.c new file +4
-0+/* +* Setting a 600 * 2.78us * 30 = 50ms integration time as the default +* for now. +*/
cite the datasheet's typical config, that also answers Andy's "magic 600".
Signature · 2 lines
cheers, jose a. p-a
Jonathan Cameron
maintainerQuoted 7 lines · On Tue, 13 Oct 2026 19:56:37 +0800 Chang Yu <[email protected]> wrote:
This series adds initial support for the AMS AS7343 14-channel multi-spectral sensor.
The sensor has 14 optical channels (11 visible + NIR + clear + flicker) in total. This initial driver supports reading raw counts from all 12 spectral channels (11 visible + NIR) via sysfs and basic power management.
FWIW I took a quick glance through and have nothing to add to the bits others have hightlighted.
Fingers crossed, we should be good to merge v7!
Jonathan