* [PATCH v3 1/7] iio: light: stk3310: migrate to devm_* API
2026-11-22 17:15 [PATCH v3 0/7] iio: light: stk3310: refactoring and new chip support Roman Vivchar via B4 Relay
@ 2026-11-22 17:15 ` Roman Vivchar via B4 Relay
2026-11-22 17:15 ` [PATCH v3 2/7] dt-bindings: iio: light: stk33xx: add power supply support Roman Vivchar via B4 Relay
` (6 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Roman Vivchar via B4 Relay @ 2026-11-22 17:15 UTC (permalink / raw)
To: Jonathan Cameron, David Lechner, Nuno Sá,
Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley
Cc: Joshua Crofts, linux-iio, devicetree, linux-kernel, Roman Vivchar
From: Roman Vivchar <rva333@protonmail.com>
Replace manual .remove() and mutex_init() with devm_* helpers for
consistency with existing devm_request_threaded_irq().
Suggested-by: Joshua Crofts <crofts@kernel.org>
Signed-off-by: Roman Vivchar <rva333@protonmail.com>
---
drivers/iio/light/stk3310.c | 37 +++++++++++++++++--------------------
1 file changed, 17 insertions(+), 20 deletions(-)
diff --git a/drivers/iio/light/stk3310.c b/drivers/iio/light/stk3310.c
index e751e7c97bc1..708ac0503be0 100644
--- a/drivers/iio/light/stk3310.c
+++ b/drivers/iio/light/stk3310.c
@@ -10,6 +10,7 @@
#include <linux/array_size.h>
#include <linux/bits.h>
#include <linux/dev_printk.h>
+#include <linux/device/devres.h>
#include <linux/err.h>
#include <linux/i2c.h>
#include <linux/interrupt.h>
@@ -594,6 +595,11 @@ static int stk3310_set_state(struct stk3310_data *data, u8 state)
return ret;
}
+static void stk3310_standby(void *data)
+{
+ stk3310_set_state(data, STK3310_STATE_STANDBY);
+}
+
static int stk3310_init(struct iio_dev *indio_dev)
{
int ret;
@@ -617,6 +623,10 @@ static int stk3310_init(struct iio_dev *indio_dev)
return ret;
}
+ ret = devm_add_action_or_reset(&client->dev, stk3310_standby, data);
+ if (ret)
+ return ret;
+
/* Enable PS interrupts */
ret = regmap_field_write(data->reg_int_ps, STK3310_PSINT_EN);
if (ret < 0) {
@@ -745,7 +755,9 @@ static int stk3310_probe(struct i2c_client *client)
device_property_read_u32(&client->dev, "proximity-near-level",
&data->ps_near_level);
- mutex_init(&data->lock);
+ ret = devm_mutex_init(dev, &data->lock);
+ if (ret)
+ return ret;
ret = stk3310_regmap_init(data);
if (ret < 0)
@@ -769,28 +781,14 @@ static int stk3310_probe(struct i2c_client *client)
IRQF_ONESHOT,
"stk3310_event", indio_dev);
if (ret)
- goto err_standby;
+ return ret;
}
- ret = iio_device_register(indio_dev);
- if (ret < 0) {
- dev_err(&client->dev, "device_register failed\n");
- goto err_standby;
- }
+ ret = devm_iio_device_register(dev, indio_dev);
+ if (ret < 0)
+ return dev_err_probe(dev, ret, "device_register failed\n");
return 0;
-
-err_standby:
- stk3310_set_state(data, STK3310_STATE_STANDBY);
- return ret;
-}
-
-static void stk3310_remove(struct i2c_client *client)
-{
- struct iio_dev *indio_dev = i2c_get_clientdata(client);
-
- iio_device_unregister(indio_dev);
- stk3310_set_state(iio_priv(indio_dev), STK3310_STATE_STANDBY);
}
static int stk3310_suspend(struct device *dev)
@@ -896,7 +894,6 @@ static struct i2c_driver stk3310_driver = {
.acpi_match_table = stk3310_acpi_id,
},
.probe = stk3310_probe,
- .remove = stk3310_remove,
.id_table = stk3310_i2c_id,
};
--
2.56.1
^ permalink raw reply [flat|nested] 10+ messages in thread* [PATCH v3 2/7] dt-bindings: iio: light: stk33xx: add power supply support
2026-11-22 17:15 [PATCH v3 0/7] iio: light: stk3310: refactoring and new chip support Roman Vivchar via B4 Relay
2026-11-22 17:15 ` [PATCH v3 1/7] iio: light: stk3310: migrate to devm_* API Roman Vivchar via B4 Relay
@ 2026-11-22 17:15 ` Roman Vivchar via B4 Relay
2026-11-22 17:15 ` [PATCH v3 3/7] iio: light: stk3310: add vdd regulator support Roman Vivchar via B4 Relay
` (5 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Roman Vivchar via B4 Relay @ 2026-11-22 17:15 UTC (permalink / raw)
To: Jonathan Cameron, David Lechner, Nuno Sá,
Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley
Cc: Joshua Crofts, linux-iio, devicetree, linux-kernel,
Roman Vivchar, Conor Dooley
From: Roman Vivchar <rva333@protonmail.com>
On some boards, the chip shares a power rail with other components. If
that rail is turned off, the chip can't function.
Add vdd-supply property to document the chip power supply.
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Roman Vivchar <rva333@protonmail.com>
---
Documentation/devicetree/bindings/iio/light/stk33xx.yaml | 2 ++
1 file changed, 2 insertions(+)
diff --git a/Documentation/devicetree/bindings/iio/light/stk33xx.yaml b/Documentation/devicetree/bindings/iio/light/stk33xx.yaml
index f655a570aac7..114cf87eb54d 100644
--- a/Documentation/devicetree/bindings/iio/light/stk33xx.yaml
+++ b/Documentation/devicetree/bindings/iio/light/stk33xx.yaml
@@ -37,6 +37,8 @@ properties:
proximity-near-level: true
+ vdd-supply: true
+
required:
- compatible
- reg
--
2.56.1
^ permalink raw reply [flat|nested] 10+ messages in thread* [PATCH v3 3/7] iio: light: stk3310: add vdd regulator support
2026-11-22 17:15 [PATCH v3 0/7] iio: light: stk3310: refactoring and new chip support Roman Vivchar via B4 Relay
2026-11-22 17:15 ` [PATCH v3 1/7] iio: light: stk3310: migrate to devm_* API Roman Vivchar via B4 Relay
2026-11-22 17:15 ` [PATCH v3 2/7] dt-bindings: iio: light: stk33xx: add power supply support Roman Vivchar via B4 Relay
@ 2026-11-22 17:15 ` Roman Vivchar via B4 Relay
2026-11-22 17:15 ` [PATCH v3 4/7] dt-bindings: iio: light: stk33xx: add stk3337 Roman Vivchar via B4 Relay
` (4 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Roman Vivchar via B4 Relay @ 2026-11-22 17:15 UTC (permalink / raw)
To: Jonathan Cameron, David Lechner, Nuno Sá,
Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley
Cc: Joshua Crofts, linux-iio, devicetree, linux-kernel, Roman Vivchar
From: Roman Vivchar <rva333@protonmail.com>
On some boards, the sensor is powered by shared power rail. If the rail
is powered down, the chip can't function.
Add vdd regulator support to ensure the power supply is enabled for the
chip.
Signed-off-by: Roman Vivchar <rva333@protonmail.com>
---
drivers/iio/light/stk3310.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/iio/light/stk3310.c b/drivers/iio/light/stk3310.c
index 708ac0503be0..828c3404215e 100644
--- a/drivers/iio/light/stk3310.c
+++ b/drivers/iio/light/stk3310.c
@@ -19,6 +19,7 @@
#include <linux/pm.h>
#include <linux/property.h>
#include <linux/regmap.h>
+#include <linux/regulator/consumer.h>
#include <linux/sysfs.h>
#include <linux/types.h>
@@ -759,6 +760,10 @@ static int stk3310_probe(struct i2c_client *client)
if (ret)
return ret;
+ ret = devm_regulator_get_enable(dev, "vdd");
+ if (ret)
+ return dev_err_probe(dev, ret, "failed to get vdd supply\n");
+
ret = stk3310_regmap_init(data);
if (ret < 0)
return ret;
--
2.56.1
^ permalink raw reply [flat|nested] 10+ messages in thread* [PATCH v3 4/7] dt-bindings: iio: light: stk33xx: add stk3337
2026-11-22 17:15 [PATCH v3 0/7] iio: light: stk3310: refactoring and new chip support Roman Vivchar via B4 Relay
` (2 preceding siblings ...)
2026-11-22 17:15 ` [PATCH v3 3/7] iio: light: stk3310: add vdd regulator support Roman Vivchar via B4 Relay
@ 2026-11-22 17:15 ` Roman Vivchar via B4 Relay
2026-11-22 17:15 ` [PATCH v3 5/7] iio: light: stk3310: add stk3337 support Roman Vivchar via B4 Relay
` (3 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Roman Vivchar via B4 Relay @ 2026-11-22 17:15 UTC (permalink / raw)
To: Jonathan Cameron, David Lechner, Nuno Sá,
Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley
Cc: Joshua Crofts, linux-iio, devicetree, linux-kernel,
Roman Vivchar, Conor Dooley
From: Roman Vivchar <rva333@protonmail.com>
Add compatible string for the stk3337 ALSPS sensor. Its core registers
are backwards compatible with the stk3310, while also providing a clear
light channel like the stk36c61, so document it with sensortek,stk3310
as a fallback.
Datasheet: https://www.bestmodulescorp.com/en/amfile/file/download/file/1699/product/1048/
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Roman Vivchar <rva333@protonmail.com>
---
Documentation/devicetree/bindings/iio/light/stk33xx.yaml | 1 +
1 file changed, 1 insertion(+)
diff --git a/Documentation/devicetree/bindings/iio/light/stk33xx.yaml b/Documentation/devicetree/bindings/iio/light/stk33xx.yaml
index 114cf87eb54d..d5d7059fbc0f 100644
--- a/Documentation/devicetree/bindings/iio/light/stk33xx.yaml
+++ b/Documentation/devicetree/bindings/iio/light/stk33xx.yaml
@@ -26,6 +26,7 @@ properties:
- items:
- enum:
- sensortek,stk3013
+ - sensortek,stk3337
- sensortek,stk36c61
- const: sensortek,stk3310
--
2.56.1
^ permalink raw reply [flat|nested] 10+ messages in thread* [PATCH v3 5/7] iio: light: stk3310: add stk3337 support
2026-11-22 17:15 [PATCH v3 0/7] iio: light: stk3310: refactoring and new chip support Roman Vivchar via B4 Relay
` (3 preceding siblings ...)
2026-11-22 17:15 ` [PATCH v3 4/7] dt-bindings: iio: light: stk33xx: add stk3337 Roman Vivchar via B4 Relay
@ 2026-11-22 17:15 ` Roman Vivchar via B4 Relay
2026-11-22 17:15 ` [PATCH v3 6/7] dt-bindings: iio: light: stk33xx: add stk3331 Roman Vivchar via B4 Relay
` (2 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Roman Vivchar via B4 Relay @ 2026-11-22 17:15 UTC (permalink / raw)
To: Jonathan Cameron, David Lechner, Nuno Sá,
Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley
Cc: Joshua Crofts, linux-iio, devicetree, linux-kernel, Roman Vivchar
From: Roman Vivchar <rva333@protonmail.com>
Add support for the stk3337 sensor, found in the Xiaomi Redmi Note 9
phone.
The stk3337 is a subset of the stk36c61. It provides the stk3310 ambient
light and proximity channels along with the clear intensity channel from
the stk36c61, but lacks the red, green, and blue intensity channels.
Datasheet: https://www.bestmodulescorp.com/en/amfile/file/download/file/1699/product/1048/
Reviewed-by: Joshua Crofts <crofts@kernel.org>
Signed-off-by: Roman Vivchar <rva333@protonmail.com>
---
drivers/iio/light/stk3310.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/drivers/iio/light/stk3310.c b/drivers/iio/light/stk3310.c
index 828c3404215e..83f40714b972 100644
--- a/drivers/iio/light/stk3310.c
+++ b/drivers/iio/light/stk3310.c
@@ -61,6 +61,7 @@
#define STK3311S34_CHIP_ID_VAL 0x1E
#define STK3311X_CHIP_ID_VAL 0x12
#define STK3335_CHIP_ID_VAL 0x51
+#define STK3337_CHIP_ID_VAL 0x5F
#define STK36C61_CHIP_ID_VAL 0x95
#define STK3310_PSINT_EN 0x01
#define STK3310_PS_MAX_VAL 0xFFFF
@@ -112,6 +113,7 @@ static const u8 stk3310_chip_ids[] = {
STK3311X_CHIP_ID_VAL,
STK3311_CHIP_ID_VAL,
STK3335_CHIP_ID_VAL,
+ STK3337_CHIP_ID_VAL,
STK36C61_CHIP_ID_VAL,
};
@@ -234,6 +236,12 @@ static const struct iio_chan_spec stk3310_channels[] = {
STK3310_PROXIMITY_CHANNEL,
};
+static const struct iio_chan_spec stk3337_channels[] = {
+ STK3310_LIGHT_CHANNEL,
+ STK3310_PROXIMITY_CHANNEL,
+ STK36C61_INTENSITY_CHANNEL(CLEAR, STK36C61_REG_CLEAR_DATA_MSB),
+};
+
static const struct iio_chan_spec stk36c61_channels[] = {
STK3310_LIGHT_CHANNEL,
STK3310_PROXIMITY_CHANNEL,
@@ -261,6 +269,12 @@ static const struct stk3310_chip_info stk3310_chip_info = {
.num_channels = ARRAY_SIZE(stk3310_channels),
};
+static const struct stk3310_chip_info stk3337_chip_info = {
+ .name = "stk3337",
+ .channels = stk3337_channels,
+ .num_channels = ARRAY_SIZE(stk3337_channels),
+};
+
static const struct stk3310_chip_info stk36c61_chip_info = {
.name = "stk36c61",
.channels = stk36c61_channels,
@@ -868,6 +882,7 @@ static const struct i2c_device_id stk3310_i2c_id[] = {
{ .name = "stk3310", .driver_data = (kernel_ulong_t)&stk3310_chip_info },
{ .name = "stk3311", .driver_data = (kernel_ulong_t)&stk3310_chip_info },
{ .name = "stk3335", .driver_data = (kernel_ulong_t)&stk3310_chip_info },
+ { .name = "stk3337", .driver_data = (kernel_ulong_t)&stk3337_chip_info },
{ .name = "stk36c61", .driver_data = (kernel_ulong_t)&stk36c61_chip_info },
{ }
};
@@ -886,6 +901,7 @@ static const struct of_device_id stk3310_of_match[] = {
{ .compatible = "sensortek,stk3310", .data = &stk3310_chip_info },
{ .compatible = "sensortek,stk3311", .data = &stk3310_chip_info },
{ .compatible = "sensortek,stk3335", .data = &stk3310_chip_info },
+ { .compatible = "sensortek,stk3337", .data = &stk3337_chip_info },
{ .compatible = "sensortek,stk36c61", .data = &stk36c61_chip_info },
{ }
};
--
2.56.1
^ permalink raw reply [flat|nested] 10+ messages in thread* [PATCH v3 6/7] dt-bindings: iio: light: stk33xx: add stk3331
2026-11-22 17:15 [PATCH v3 0/7] iio: light: stk3310: refactoring and new chip support Roman Vivchar via B4 Relay
` (4 preceding siblings ...)
2026-11-22 17:15 ` [PATCH v3 5/7] iio: light: stk3310: add stk3337 support Roman Vivchar via B4 Relay
@ 2026-11-22 17:15 ` Roman Vivchar via B4 Relay
2026-11-23 17:07 ` Conor Dooley
2026-11-22 17:15 ` [PATCH v3 7/7] iio: light: stk3310: add STK3331-A support Roman Vivchar via B4 Relay
2026-11-28 23:41 ` [PATCH v3 0/7] iio: light: stk3310: refactoring and new chip support Jonathan Cameron
7 siblings, 1 reply; 10+ messages in thread
From: Roman Vivchar via B4 Relay @ 2026-11-22 17:15 UTC (permalink / raw)
To: Jonathan Cameron, David Lechner, Nuno Sá,
Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley
Cc: Joshua Crofts, linux-iio, devicetree, linux-kernel, Roman Vivchar
From: Roman Vivchar <rva333@protonmail.com>
STK3331 is a STK3337 variant with slightly bigger package. It has the
same Clear channel and register map. Add a compatible string for it.
Signed-off-by: Roman Vivchar <rva333@protonmail.com>
---
Documentation/devicetree/bindings/iio/light/stk33xx.yaml | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/Documentation/devicetree/bindings/iio/light/stk33xx.yaml b/Documentation/devicetree/bindings/iio/light/stk33xx.yaml
index d5d7059fbc0f..2e91158921fe 100644
--- a/Documentation/devicetree/bindings/iio/light/stk33xx.yaml
+++ b/Documentation/devicetree/bindings/iio/light/stk33xx.yaml
@@ -29,6 +29,10 @@ properties:
- sensortek,stk3337
- sensortek,stk36c61
- const: sensortek,stk3310
+ - items:
+ - const: sensortek,stk3331
+ - const: sensortek,stk3337
+ - const: sensortek,stk3310
reg:
maxItems: 1
--
2.56.1
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH v3 6/7] dt-bindings: iio: light: stk33xx: add stk3331
2026-11-22 17:15 ` [PATCH v3 6/7] dt-bindings: iio: light: stk33xx: add stk3331 Roman Vivchar via B4 Relay
@ 2026-11-23 17:07 ` Conor Dooley
0 siblings, 0 replies; 10+ messages in thread
From: Conor Dooley @ 2026-11-23 17:07 UTC (permalink / raw)
To: rva333
Cc: Jonathan Cameron, David Lechner, Nuno Sá,
Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Joshua Crofts, linux-iio, devicetree, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 75 bytes --]
Acked-by: Conor Dooley <conor.dooley@microchip.com>
pw-bot: not-applicable
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v3 7/7] iio: light: stk3310: add STK3331-A support
2026-11-22 17:15 [PATCH v3 0/7] iio: light: stk3310: refactoring and new chip support Roman Vivchar via B4 Relay
` (5 preceding siblings ...)
2026-11-22 17:15 ` [PATCH v3 6/7] dt-bindings: iio: light: stk33xx: add stk3331 Roman Vivchar via B4 Relay
@ 2026-11-22 17:15 ` Roman Vivchar via B4 Relay
2026-11-28 23:41 ` [PATCH v3 0/7] iio: light: stk3310: refactoring and new chip support Jonathan Cameron
7 siblings, 0 replies; 10+ messages in thread
From: Roman Vivchar via B4 Relay @ 2026-11-22 17:15 UTC (permalink / raw)
To: Jonathan Cameron, David Lechner, Nuno Sá,
Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley
Cc: Joshua Crofts, linux-iio, devicetree, linux-kernel, Roman Vivchar
From: Roman Vivchar <rva333@protonmail.com>
STK3331 is a STK3337 with slightly bigger package. Add support for the A
revision.
Signed-off-by: Roman Vivchar <rva333@protonmail.com>
---
A revision has different chip ID compared to the base STK3331, but
otherwise chips are identical. Only this revision is added since I have
no other hardware with stk3331.
---
drivers/iio/light/stk3310.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/iio/light/stk3310.c b/drivers/iio/light/stk3310.c
index 83f40714b972..8f640ab10677 100644
--- a/drivers/iio/light/stk3310.c
+++ b/drivers/iio/light/stk3310.c
@@ -60,6 +60,7 @@
#define STK3311A_CHIP_ID_VAL 0x15
#define STK3311S34_CHIP_ID_VAL 0x1E
#define STK3311X_CHIP_ID_VAL 0x12
+#define STK3331A_CHIP_ID_VAL 0x5E
#define STK3335_CHIP_ID_VAL 0x51
#define STK3337_CHIP_ID_VAL 0x5F
#define STK36C61_CHIP_ID_VAL 0x95
@@ -112,6 +113,7 @@ static const u8 stk3310_chip_ids[] = {
STK3311S34_CHIP_ID_VAL,
STK3311X_CHIP_ID_VAL,
STK3311_CHIP_ID_VAL,
+ STK3331A_CHIP_ID_VAL,
STK3335_CHIP_ID_VAL,
STK3337_CHIP_ID_VAL,
STK36C61_CHIP_ID_VAL,
--
2.56.1
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH v3 0/7] iio: light: stk3310: refactoring and new chip support
2026-11-22 17:15 [PATCH v3 0/7] iio: light: stk3310: refactoring and new chip support Roman Vivchar via B4 Relay
` (6 preceding siblings ...)
2026-11-22 17:15 ` [PATCH v3 7/7] iio: light: stk3310: add STK3331-A support Roman Vivchar via B4 Relay
@ 2026-11-28 23:41 ` Jonathan Cameron
7 siblings, 0 replies; 10+ messages in thread
From: Jonathan Cameron @ 2026-11-28 23:41 UTC (permalink / raw)
To: Roman Vivchar via B4 Relay
Cc: rva333, David Lechner, Nuno Sá,
Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Joshua Crofts, linux-iio, devicetree, linux-kernel, Conor Dooley
On Sun, 22 Nov 2026 19:15:41 +0200
Roman Vivchar via B4 Relay <devnull+rva333.protonmail.com@kernel.org> wrote:
> This patch series adds support for stk3337 light sensor, found in the
> Xiaomi Redmi Note 9 phone. The sensor is compatible with stk3310
> registers, while having Clear channel, similar to the stk36c61.
>
> It also adds support for stk3331-a sensor in Realme C3 phone.
> It's stk3337 but in a different package.
>
> Additionally, there's patch for vdd-supply property, since sensor can be
> wired to the shared power supply.
>
> Signed-off-by: Roman Vivchar <rva333@protonmail.com>
Applied to the testing branch of iio.git (so lined up for next merge window)
Thanks,
Jonathan
^ permalink raw reply [flat|nested] 10+ messages in thread