Message ID | 20231208102211.413019-1-anshulusr@gmail.com |
---|---|
State | Not Applicable |
Headers | show |
Series | [v3,1/2] dt-bindings: iio: light: add ltr390 | expand |
Context | Check | Description |
---|---|---|
robh/checkpatch | warning | total: 0 errors, 2 warnings, 56 lines checked |
robh/patch-applied | success | |
robh/dtbs-check | warning | build log |
robh/dt-meta-schema | success |
On Fri, 8 Dec 2023 15:52:10 +0530 Anshul Dalal <anshulusr@gmail.com> wrote: > Implements driver for the Ambient/UV Light sensor LTR390. > The driver exposes two ways of getting sensor readings: > 1. Raw UV Counts directly from the sensor > 2. The computed UV Index value with a percision of 2 decimal places > > [NOTE] Ambient light sensing has not been implemented yet. > > Driver tested on RPi Zero 2W > > Datasheet: https://optoelectronics.liteon.com/upload/download/DS86-2015-0004/LTR-390UV_Final_%20DS_V1%201.pdf > Signed-off-by: Anshul Dalal <anshulusr@gmail.com> I fixed up the case where you use dev_err_probe() in a path called from places other than the probe() callback. Applied to the togreg branch of iio.git and initially pushed out as testing for 0-day to take a look and see if it can find things we missed Thanks, Jonathan > + > +static int ltr390_register_read(struct ltr390_data *data, u8 register_address) > +{ > + struct device *dev = &data->client->dev; > + int ret; > + u8 recieve_buffer[3]; > + > + guard(mutex)(&data->lock); > + > + ret = regmap_bulk_read(data->regmap, register_address, recieve_buffer, > + sizeof(recieve_buffer)); > + if (ret) > + return dev_err_probe(dev, ret, dev_err_probe() is only intended for use in probe() and functions that are only called from probe() > + "failed to read measurement data"); > + > + return get_unaligned_le24(recieve_buffer); > +}
diff --git a/Documentation/devicetree/bindings/iio/light/liteon,ltr390.yaml b/Documentation/devicetree/bindings/iio/light/liteon,ltr390.yaml new file mode 100644 index 000000000000..5d98ef2af74d --- /dev/null +++ b/Documentation/devicetree/bindings/iio/light/liteon,ltr390.yaml @@ -0,0 +1,56 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/light/liteon,ltr390.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Lite-On LTR390 ALS and UV Sensor + +description: | + The Lite-On LTR390 is an ALS (Ambient Light Sensor) and a UV sensor in a + single package with i2c address of 0x53. + + Datasheet: + https://optoelectronics.liteon.com/upload/download/DS86-2015-0004/LTR-390UV_Final_%20DS_V1%201.pdf + +maintainers: + - Anshul Dalal <anshulusr@gmail.com> + +properties: + compatible: + enum: + - liteon,ltr390 + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + description: | + Level interrupt pin with open drain output. + The sensor pulls this pin low when the measured reading is greater than + some configured threshold. + + vdd-supply: true + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/irq.h> + + i2c { + #address-cells = <1>; + #size-cells = <0>; + + light-sensor@53 { + compatible = "liteon,ltr390"; + reg = <0x53>; + interrupts = <18 IRQ_TYPE_EDGE_FALLING>; + vdd-supply = <&vdd_regulator>; + }; + };