From: Esben Haabendal <esben@geanix.com>
To: "Jonathan Cameron" <jic23@kernel.org>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Nikita Travkin" <nikita@trvn.ru>,
"Maslov Dmitry" <maslovdmitry@seeed.cc>,
"Kuppuswamy Sathyanarayanan"
<sathyanarayanan.kuppuswamy@linux.intel.com>,
"Thomas Gleixner" <tglx@kernel.org>,
"Pan Chuang" <panchuang@vivo.com>,
"Yangtao Li" <frank.li@vivo.com>
Cc: Esben Haabendal <esben@geanix.com>,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org,
Jonathan Cameron <jic23@kernel.org>
Subject: [PATCH v4 6/7] iio: light: ltr501: Add ltr329 driver support
Date: Mon, 10 Aug 2026 09:11:16 +0200 [thread overview]
Message-ID: <20260810-liteon-ltr329-v4-6-8bd3dfd15280@geanix.com> (raw)
In-Reply-To: <20260810-liteon-ltr329-v4-0-8bd3dfd15280@geanix.com>
This adds support for the LTR-329ALS-01 chip, which is similar to
LTR-303ALS-01, except for interrupt, which LTR-329ALS-01 chip does not
have.
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Acked-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
Signed-off-by: Esben Haabendal <esben@geanix.com>
---
drivers/iio/light/ltr501.c | 48 ++++++++++++++++++++++++++++++++++++++++------
1 file changed, 42 insertions(+), 6 deletions(-)
diff --git a/drivers/iio/light/ltr501.c b/drivers/iio/light/ltr501.c
index b36bd10a0262..cd5ff00ef5e2 100644
--- a/drivers/iio/light/ltr501.c
+++ b/drivers/iio/light/ltr501.c
@@ -9,6 +9,7 @@
* TODO: IR LED characteristics
*/
+#include <linux/array_size.h>
#include <linux/module.h>
#include <linux/i2c.h>
#include <linux/err.h>
@@ -94,6 +95,7 @@ enum {
ltr559,
ltr301,
ltr303,
+ ltr329,
};
struct ltr501_gain {
@@ -140,6 +142,7 @@ struct ltr501_chip_info {
u8 als_mode_active;
u8 als_gain_mask;
u8 als_gain_shift;
+ bool no_irq_support;
struct iio_chan_spec const *channels;
const int no_channels;
const struct iio_info *info;
@@ -178,6 +181,11 @@ static const struct ltr501_samp_table ltr501_ps_samp_table[] = {
{500000, 2000000}
};
+static bool ltr501_has_irq_support(const struct ltr501_chip_info *info)
+{
+ return !info->no_irq_support;
+}
+
static int ltr501_match_samp_freq(const struct ltr501_samp_table *tab,
int len, int val, int val2)
{
@@ -821,6 +829,9 @@ static int __ltr501_write_raw(struct iio_dev *indio_dev,
if (ret < 0)
return ret;
+ if (!ltr501_has_irq_support(info))
+ return ret;
+
/* update persistence count when changing frequency */
ret = ltr501_write_intr_prst(data, chan->type,
0, data->als_period);
@@ -840,6 +851,9 @@ static int __ltr501_write_raw(struct iio_dev *indio_dev,
if (ret < 0)
return ret;
+ if (!ltr501_has_irq_support(info))
+ return ret;
+
/* update persistence count when changing frequency */
ret = ltr501_write_intr_prst(data, chan->type,
0, data->ps_period);
@@ -1257,6 +1271,18 @@ static const struct ltr501_chip_info ltr501_chip_info_tbl[] = {
.channels = ltr301_channels,
.no_channels = ARRAY_SIZE(ltr301_channels),
},
+ [ltr329] = {
+ .partid = 0x0A,
+ .als_gain = ltr559_als_gain_tbl,
+ .als_gain_tbl_size = ARRAY_SIZE(ltr559_als_gain_tbl),
+ .als_mode_active = BIT(0),
+ .als_gain_mask = BIT(2) | BIT(3) | BIT(4),
+ .als_gain_shift = 2,
+ .no_irq_support = true,
+ .info_no_irq = <r301_info_no_irq,
+ .channels = ltr301_channels,
+ .no_channels = ARRAY_SIZE(ltr301_channels),
+ },
};
static int ltr501_write_contr(struct ltr501_data *data, u8 als_val, u8 ps_val)
@@ -1369,13 +1395,15 @@ static int ltr501_init(struct ltr501_data *data)
data->ps_contr = status | LTR501_CONTR_ACTIVE;
- ret = ltr501_read_intr_prst(data, IIO_INTENSITY, &data->als_period);
- if (ret < 0)
- return ret;
+ if (ltr501_has_irq_support(data->chip_info)) {
+ ret = ltr501_read_intr_prst(data, IIO_INTENSITY, &data->als_period);
+ if (ret < 0)
+ return ret;
- ret = ltr501_read_intr_prst(data, IIO_PROXIMITY, &data->ps_period);
- if (ret < 0)
- return ret;
+ ret = ltr501_read_intr_prst(data, IIO_PROXIMITY, &data->ps_period);
+ if (ret < 0)
+ return ret;
+ }
return ltr501_write_contr(data, data->als_contr, data->ps_contr);
}
@@ -1531,6 +1559,12 @@ static int ltr501_probe(struct i2c_client *client)
return ret;
if (client->irq > 0) {
+ if (!ltr501_has_irq_support(data->chip_info)) {
+ ret = dev_err_probe(&client->dev, -EINVAL,
+ "chip does not support irq\n");
+ goto powerdown_on_error;
+ }
+
ret = devm_request_threaded_irq(&client->dev, client->irq,
NULL, ltr501_interrupt_handler,
IRQF_TRIGGER_FALLING |
@@ -1601,6 +1635,7 @@ static const struct i2c_device_id ltr501_id[] = {
{ .name = "ltr559", .driver_data = ltr559 },
{ .name = "ltr301", .driver_data = ltr301 },
{ .name = "ltr303", .driver_data = ltr303 },
+ { .name = "ltr329", .driver_data = ltr329 },
{ }
};
MODULE_DEVICE_TABLE(i2c, ltr501_id);
@@ -1610,6 +1645,7 @@ static const struct of_device_id ltr501_of_match[] = {
{ .compatible = "liteon,ltr559", },
{ .compatible = "liteon,ltr301", },
{ .compatible = "liteon,ltr303", },
+ { .compatible = "liteon,ltr329", },
{ }
};
MODULE_DEVICE_TABLE(of, ltr501_of_match);
--
2.55.0
next prev parent reply other threads:[~2026-08-10 7:11 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-10 7:11 [PATCH v4 0/7] iio: light: ltr501: Add ltr329 support Esben Haabendal
2026-08-10 7:11 ` [PATCH v4 1/7] dt-bindings: iio: light: ltr501: Sort compatible enum array Esben Haabendal
2026-08-10 7:11 ` [PATCH v4 2/7] dt-bindings: iio: light: ltr501: Add missing ltr303 compatible Esben Haabendal
2026-08-10 7:11 ` [PATCH v4 3/7] dt-bindings: iio: light: ltr501: Add ltr329 compatible Esben Haabendal
2026-08-10 7:19 ` sashiko-bot
2026-08-10 15:50 ` Rob Herring
2026-08-10 7:11 ` [PATCH v4 4/7] iio: light: ltr501: Power down chip if request irq fails Esben Haabendal
2026-08-10 7:23 ` sashiko-bot
2026-08-10 7:11 ` [PATCH v4 5/7] iio: light: ltr501: Fix duplicated error message Esben Haabendal
2026-08-10 7:11 ` Esben Haabendal [this message]
2026-08-10 7:24 ` [PATCH v4 6/7] iio: light: ltr501: Add ltr329 driver support sashiko-bot
2026-08-10 19:57 ` Andy Shevchenko
2026-08-10 7:11 ` [PATCH v4 7/7] iio: light: ltr501: Fix sorting order of device arrays Esben Haabendal
2026-08-10 19:59 ` [PATCH v4 0/7] iio: light: ltr501: Add ltr329 support Andy Shevchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260810-liteon-ltr329-v4-6-8bd3dfd15280@geanix.com \
--to=esben@geanix.com \
--cc=andy@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=frank.li@vivo.com \
--cc=jic23@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maslovdmitry@seeed.cc \
--cc=nikita@trvn.ru \
--cc=nuno.sa@analog.com \
--cc=panchuang@vivo.com \
--cc=robh@kernel.org \
--cc=sathyanarayanan.kuppuswamy@linux.intel.com \
--cc=tglx@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox