* [PATCH 1/2] dt-bindings: iio: light: ltr501: Add proximity-near-level @ 2021-11-25 12:56 Nikita Travkin 2021-11-25 12:56 ` [PATCH 2/2] iio: ltr501: Export near level property for proximity sensor Nikita Travkin 2021-12-01 22:25 ` [PATCH 1/2] dt-bindings: iio: light: ltr501: Add proximity-near-level Rob Herring 0 siblings, 2 replies; 5+ messages in thread From: Nikita Travkin @ 2021-11-25 12:56 UTC (permalink / raw) To: jic23; +Cc: lars, robh+dt, linux-iio, devicetree, linux-kernel, Nikita Travkin This value inidcates the proximity level that should be considered "close". Signed-off-by: Nikita Travkin <nikita@trvn.ru> --- .../devicetree/bindings/iio/light/liteon,ltr501.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Documentation/devicetree/bindings/iio/light/liteon,ltr501.yaml b/Documentation/devicetree/bindings/iio/light/liteon,ltr501.yaml index db0407bc9209..c8074f180a79 100644 --- a/Documentation/devicetree/bindings/iio/light/liteon,ltr501.yaml +++ b/Documentation/devicetree/bindings/iio/light/liteon,ltr501.yaml @@ -9,6 +9,9 @@ title: LiteON LTR501 I2C Proximity and Light sensor maintainers: - Nikita Travkin <nikita@trvn.ru> +allOf: + - $ref: ../common.yaml# + properties: compatible: enum: @@ -25,6 +28,8 @@ properties: interrupts: maxItems: 1 + proximity-near-level: true + additionalProperties: false required: @@ -42,6 +47,8 @@ examples: light-sensor@23 { compatible = "liteon,ltr559"; reg = <0x23>; + proximity-near-level = <75>; + vdd-supply = <&pm8916_l17>; vddio-supply = <&pm8916_l6>; -- 2.30.2 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] iio: ltr501: Export near level property for proximity sensor 2021-11-25 12:56 [PATCH 1/2] dt-bindings: iio: light: ltr501: Add proximity-near-level Nikita Travkin @ 2021-11-25 12:56 ` Nikita Travkin 2021-11-27 18:49 ` Jonathan Cameron 2021-12-01 22:25 ` [PATCH 1/2] dt-bindings: iio: light: ltr501: Add proximity-near-level Rob Herring 1 sibling, 1 reply; 5+ messages in thread From: Nikita Travkin @ 2021-11-25 12:56 UTC (permalink / raw) To: jic23; +Cc: lars, robh+dt, linux-iio, devicetree, linux-kernel, Nikita Travkin Userspace tools like iio-sensor-proxy need to know the proximity level that should be considered "near". This value is hardware-specific and can be defined via the devicetree. Allow the driver to export the near level. Signed-off-by: Nikita Travkin <nikita@trvn.ru> --- The changes are mostly copied from vcnl4000 patchset introducing the property: https://lore.kernel.org/linux-iio/cover.1586094535.git.agx@sigxcpu.org/ --- drivers/iio/light/ltr501.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/iio/light/ltr501.c b/drivers/iio/light/ltr501.c index 64ba04c275e8..47d61ec2bb50 100644 --- a/drivers/iio/light/ltr501.c +++ b/drivers/iio/light/ltr501.c @@ -166,6 +166,7 @@ struct ltr501_data { struct regmap_field *reg_ps_rate; struct regmap_field *reg_als_prst; struct regmap_field *reg_ps_prst; + uint32_t near_level; }; static const struct ltr501_samp_table ltr501_als_samp_table[] = { @@ -525,6 +526,25 @@ static int ltr501_write_intr_prst(struct ltr501_data *data, return -EINVAL; } +static ssize_t ltr501_read_near_level(struct iio_dev *indio_dev, + uintptr_t priv, + const struct iio_chan_spec *chan, + char *buf) +{ + struct ltr501_data *data = iio_priv(indio_dev); + + return sprintf(buf, "%u\n", data->near_level); +} + +static const struct iio_chan_spec_ext_info ltr501_ext_info[] = { + { + .name = "nearlevel", + .shared = IIO_SEPARATE, + .read = ltr501_read_near_level, + }, + { /* sentinel */ } +}; + static const struct iio_event_spec ltr501_als_event_spec[] = { { .type = IIO_EV_TYPE_THRESH, @@ -609,6 +629,7 @@ static const struct iio_chan_spec ltr501_channels[] = { }, .event_spec = ltr501_pxs_event_spec, .num_event_specs = ARRAY_SIZE(ltr501_pxs_event_spec), + .ext_info = ltr501_ext_info, }, IIO_CHAN_SOFT_TIMESTAMP(3), }; @@ -1531,6 +1552,10 @@ static int ltr501_probe(struct i2c_client *client, if ((partid >> 4) != data->chip_info->partid) return -ENODEV; + if (device_property_read_u32(&client->dev, "proximity-near-level", + &data->near_level)) + data->near_level = 0; + indio_dev->info = data->chip_info->info; indio_dev->channels = data->chip_info->channels; indio_dev->num_channels = data->chip_info->no_channels; -- 2.30.2 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] iio: ltr501: Export near level property for proximity sensor 2021-11-25 12:56 ` [PATCH 2/2] iio: ltr501: Export near level property for proximity sensor Nikita Travkin @ 2021-11-27 18:49 ` Jonathan Cameron 0 siblings, 0 replies; 5+ messages in thread From: Jonathan Cameron @ 2021-11-27 18:49 UTC (permalink / raw) To: Nikita Travkin; +Cc: lars, robh+dt, linux-iio, devicetree, linux-kernel On Thu, 25 Nov 2021 17:56:46 +0500 Nikita Travkin <nikita@trvn.ru> wrote: > Userspace tools like iio-sensor-proxy need to know the proximity level > that should be considered "near". This value is hardware-specific and > can be defined via the devicetree. Allow the driver to export the near > level. > > Signed-off-by: Nikita Travkin <nikita@trvn.ru> Hi Nikita, This looks fine to me, but I'd like to leave a little time for others to look including DT review. Thanks, Jonathan > > --- > The changes are mostly copied from vcnl4000 patchset introducing the > property: > https://lore.kernel.org/linux-iio/cover.1586094535.git.agx@sigxcpu.org/ > --- > drivers/iio/light/ltr501.c | 25 +++++++++++++++++++++++++ > 1 file changed, 25 insertions(+) > > diff --git a/drivers/iio/light/ltr501.c b/drivers/iio/light/ltr501.c > index 64ba04c275e8..47d61ec2bb50 100644 > --- a/drivers/iio/light/ltr501.c > +++ b/drivers/iio/light/ltr501.c > @@ -166,6 +166,7 @@ struct ltr501_data { > struct regmap_field *reg_ps_rate; > struct regmap_field *reg_als_prst; > struct regmap_field *reg_ps_prst; > + uint32_t near_level; > }; > > static const struct ltr501_samp_table ltr501_als_samp_table[] = { > @@ -525,6 +526,25 @@ static int ltr501_write_intr_prst(struct ltr501_data *data, > return -EINVAL; > } > > +static ssize_t ltr501_read_near_level(struct iio_dev *indio_dev, > + uintptr_t priv, > + const struct iio_chan_spec *chan, > + char *buf) > +{ > + struct ltr501_data *data = iio_priv(indio_dev); > + > + return sprintf(buf, "%u\n", data->near_level); > +} > + > +static const struct iio_chan_spec_ext_info ltr501_ext_info[] = { > + { > + .name = "nearlevel", > + .shared = IIO_SEPARATE, > + .read = ltr501_read_near_level, > + }, > + { /* sentinel */ } > +}; > + > static const struct iio_event_spec ltr501_als_event_spec[] = { > { > .type = IIO_EV_TYPE_THRESH, > @@ -609,6 +629,7 @@ static const struct iio_chan_spec ltr501_channels[] = { > }, > .event_spec = ltr501_pxs_event_spec, > .num_event_specs = ARRAY_SIZE(ltr501_pxs_event_spec), > + .ext_info = ltr501_ext_info, > }, > IIO_CHAN_SOFT_TIMESTAMP(3), > }; > @@ -1531,6 +1552,10 @@ static int ltr501_probe(struct i2c_client *client, > if ((partid >> 4) != data->chip_info->partid) > return -ENODEV; > > + if (device_property_read_u32(&client->dev, "proximity-near-level", > + &data->near_level)) > + data->near_level = 0; > + > indio_dev->info = data->chip_info->info; > indio_dev->channels = data->chip_info->channels; > indio_dev->num_channels = data->chip_info->no_channels; ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] dt-bindings: iio: light: ltr501: Add proximity-near-level 2021-11-25 12:56 [PATCH 1/2] dt-bindings: iio: light: ltr501: Add proximity-near-level Nikita Travkin 2021-11-25 12:56 ` [PATCH 2/2] iio: ltr501: Export near level property for proximity sensor Nikita Travkin @ 2021-12-01 22:25 ` Rob Herring 2021-12-04 15:32 ` Jonathan Cameron 1 sibling, 1 reply; 5+ messages in thread From: Rob Herring @ 2021-12-01 22:25 UTC (permalink / raw) To: Nikita Travkin; +Cc: linux-iio, devicetree, linux-kernel, lars, jic23, robh+dt On Thu, 25 Nov 2021 17:56:45 +0500, Nikita Travkin wrote: > This value inidcates the proximity level that should be considered > "close". > > Signed-off-by: Nikita Travkin <nikita@trvn.ru> > --- > .../devicetree/bindings/iio/light/liteon,ltr501.yaml | 7 +++++++ > 1 file changed, 7 insertions(+) > Reviewed-by: Rob Herring <robh@kernel.org> ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] dt-bindings: iio: light: ltr501: Add proximity-near-level 2021-12-01 22:25 ` [PATCH 1/2] dt-bindings: iio: light: ltr501: Add proximity-near-level Rob Herring @ 2021-12-04 15:32 ` Jonathan Cameron 0 siblings, 0 replies; 5+ messages in thread From: Jonathan Cameron @ 2021-12-04 15:32 UTC (permalink / raw) To: Rob Herring Cc: Nikita Travkin, linux-iio, devicetree, linux-kernel, lars, robh+dt On Wed, 1 Dec 2021 16:25:45 -0600 Rob Herring <robh@kernel.org> wrote: > On Thu, 25 Nov 2021 17:56:45 +0500, Nikita Travkin wrote: > > This value inidcates the proximity level that should be considered > > "close". > > > > Signed-off-by: Nikita Travkin <nikita@trvn.ru> > > --- > > .../devicetree/bindings/iio/light/liteon,ltr501.yaml | 7 +++++++ > > 1 file changed, 7 insertions(+) > > > > Reviewed-by: Rob Herring <robh@kernel.org> Series applied to the togreg branch of iio.git. I'll push it out as testing first to let 0-day see if it can find any problems before I go breaking next ;) Jonathan ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-12-04 15:27 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-11-25 12:56 [PATCH 1/2] dt-bindings: iio: light: ltr501: Add proximity-near-level Nikita Travkin 2021-11-25 12:56 ` [PATCH 2/2] iio: ltr501: Export near level property for proximity sensor Nikita Travkin 2021-11-27 18:49 ` Jonathan Cameron 2021-12-01 22:25 ` [PATCH 1/2] dt-bindings: iio: light: ltr501: Add proximity-near-level Rob Herring 2021-12-04 15:32 ` Jonathan Cameron
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).