From nobody Sat Sep 26 13:50:18 2026 Received: from out-zbxj-a87.jellyfish.systems (out-zbxj-a87.jellyfish.systems [198.54.127.87]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 85B3637C92C for ; Tue, 1 Sep 2026 00:52:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.54.127.87 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788223931; cv=none; b=cXH950tRA2EQOiVHVzHxSJAy6DSQB5WF328nDu+CN/R+u7a2/1qxK/rb1FQsKR+kZxb3eGoRhCMilI6TSfysvRu77ZRFF2ZNhFUG9X9n4tBoP+hKMBKl2XEWaXFHaaYFTlS3R2uEh9rhePUqbsnxMk3T4YMMlG+YowJ+i34vJh0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788223931; c=relaxed/simple; bh=Te6OgxwGgEhX6zhThy1LCdT2kCok02F1tkg/hdLPbmQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WHKy1+CBJ2hrLgfNtjqZKDZ6AdR53TnZxFz1tQ4Hi46jh1+VY4mi14GGRekgYWlNwkfAjqndA3mxnKKafJKGGu2GrhjS8yzjmdMkH7HUyX1oxtyN+rIcP8fyMxPgC6r4VlZqpH7AfULI65JcNvHI0yPqKzk+4HRkov/kmZGFdGI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=catcrafts.net; spf=pass smtp.mailfrom=catcrafts.net; arc=none smtp.client-ip=198.54.127.87 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=catcrafts.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=catcrafts.net Received: from mail.privateemail.com (unknown [87.215.145.39]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.privateemail.com (Postfix) with ESMTPSA id 4hYnP86B3Cz2x9D; Tue, 01 Sep 2026 00:51:40 +0000 (UTC) From: Jorijn van der Graaf To: Jonathan Cameron , linux-iio@vger.kernel.org Cc: David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , Andy Shevchenko , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , devicetree@vger.kernel.org, Kees Cook , "Gustavo A . R . Silva" , linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, Luca Weiss , Marcelo Schmitt , Jorijn van der Graaf Subject: [PATCH v3 1/5] iio: light: stk3310: lower-case the i2c device ID names Date: Tue, 1 Sep 2026 02:51:10 +0200 Message-ID: <20260901005114.203062-2-jorijnvdgraaf@catcrafts.net> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260901005114.203062-1-jorijnvdgraaf@catcrafts.net> References: <20260901005114.203062-1-jorijnvdgraaf@catcrafts.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Envelope-From: jorijnvdgraaf@catcrafts.net Content-Type: text/plain; charset="utf-8" The i2c device IDs were introduced in capitals, mirroring the ACPI _HID entries added by the same commit be9e6229d676 ("iio: light: Add support for Sensortek STK3310"); at that point the driver enumerated through ACPI only, with no OF table and no i2c module alias export. ACPI _HIDs have their own naming rules; i2c device names conventionally use the lower-case part name, matching the devicetree compatible suffix. The spelling is visible: a client instantiated through the i2c sysfs interface under the lower-case name taken from a compatible string binds through the OF table's name fallback, but has no firmware node, so i2c_match_id() is the only way for it to reach driver match data, and its string comparison is case-sensitive, so the capitals can never match. Lower-case the names so such clients match the id table, and receive the per-chip match data a subsequent change attaches to it. The module aliases follow the rename (i2c:STK3310 becomes i2c:stk3310), and a sysfs client instantiated under a capitals name no longer binds. Suggested-by: Andy Shevchenko Reviewed-by: Andy Shevchenko Assisted-by: Claude:claude-fable-5 Signed-off-by: Jorijn van der Graaf --- drivers/iio/light/stk3310.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/iio/light/stk3310.c b/drivers/iio/light/stk3310.c index 7c8a1d2b2ed0..5b5b6812edc7 100644 --- a/drivers/iio/light/stk3310.c +++ b/drivers/iio/light/stk3310.c @@ -766,10 +766,10 @@ static DEFINE_SIMPLE_DEV_PM_OPS(stk3310_pm_ops, stk33= 10_suspend, stk3310_resume); =20 static const struct i2c_device_id stk3310_i2c_id[] =3D { - { .name =3D "STK3013" }, - { .name =3D "STK3310" }, - { .name =3D "STK3311" }, - { .name =3D "STK3335" }, + { .name =3D "stk3013" }, + { .name =3D "stk3310" }, + { .name =3D "stk3311" }, + { .name =3D "stk3335" }, { } }; MODULE_DEVICE_TABLE(i2c, stk3310_i2c_id); --=20 2.55.0 From nobody Sat Sep 26 13:50:18 2026 Received: from out-2z4y-a139.jellyfish.systems (out-2z4y-a139.jellyfish.systems [198.54.127.139]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 38C0537DEB7 for ; Tue, 1 Sep 2026 00:52:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.54.127.139 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788223926; cv=none; b=nyh2eRZaKyAwbg2GOHG/3bLoBTQQhoY4mYt31nJ6ok6+hXNvXzRhBJsMCQci4aVQr/Zeukkl70XC9yyPNV8uzDiZe3fTisYemQo44jVR1O3Cqe5+ALdKNUT1Wy5nwqG8JW5KwXraj/qRHcvxXUzysbr8pNhIZ1mUnTHOLaPJg6k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788223926; c=relaxed/simple; bh=n8EG6axqjMnfb5vB4Ik6vvRPTgDNmmVhOQoJ89A9+Rc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HLMk7V8DcqnzXNbac3e8lGo/62WyBfZS3Ilu+4COAMQd3vW4zZm+Ch+m/U3PooObkUYiFc6DQpvXDHQR6hhOOZLiuda0MXGI4CQUeXOe/P6vp17a8nNlBoeBMqOaNgiszTJvqG/5z8G//BBRUTDya0KmepYbaQy6C68BRgbpvck= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=catcrafts.net; spf=pass smtp.mailfrom=catcrafts.net; arc=none smtp.client-ip=198.54.127.139 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=catcrafts.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=catcrafts.net Received: from mail.privateemail.com (unknown [87.215.145.39]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.privateemail.com (Postfix) with ESMTPSA id 4hYnPF1bVmz2x98; Tue, 01 Sep 2026 00:51:45 +0000 (UTC) From: Jorijn van der Graaf To: Jonathan Cameron , linux-iio@vger.kernel.org Cc: David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , Andy Shevchenko , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , devicetree@vger.kernel.org, Kees Cook , "Gustavo A . R . Silva" , linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, Luca Weiss , Marcelo Schmitt , Jorijn van der Graaf , Krzysztof Kozlowski Subject: [PATCH v3 2/5] dt-bindings: iio: light: stk33xx: document the Sensortek STK36C61 Date: Tue, 1 Sep 2026 02:51:11 +0200 Message-ID: <20260901005114.203062-3-jorijnvdgraaf@catcrafts.net> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260901005114.203062-1-jorijnvdgraaf@catcrafts.net> References: <20260901005114.203062-1-jorijnvdgraaf@catcrafts.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Envelope-From: jorijnvdgraaf@catcrafts.net Content-Type: text/plain; charset="utf-8" The STK36C61 is a 3-in-1 ambient light / proximity / RGB colour sensor found in the Fairphone 6. Its ambient light and proximity register interface is compatible with the stk3310's, while the dedicated compatible identifies the part, whose colour channels the fallback does not describe. Add sensortek,stk36c61 with a sensortek,stk3310 fallback, mirroring the stk3013 entry, and widen the title and description to cover the part. Reviewed-by: Krzysztof Kozlowski Assisted-by: Claude:claude-fable-5 Signed-off-by: Jorijn van der Graaf --- Documentation/devicetree/bindings/iio/light/stk33xx.yaml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Documentation/devicetree/bindings/iio/light/stk33xx.yaml b/Doc= umentation/devicetree/bindings/iio/light/stk33xx.yaml index e4341fdced98..0165a348918b 100644 --- a/Documentation/devicetree/bindings/iio/light/stk33xx.yaml +++ b/Documentation/devicetree/bindings/iio/light/stk33xx.yaml @@ -4,14 +4,14 @@ $id: http://devicetree.org/schemas/iio/light/stk33xx.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# =20 -title: | - Sensortek STK33xx I2C Ambient Light and Proximity sensor +title: Sensortek STK33xx/STK36C61 I2C Ambient Light and Proximity sensor =20 maintainers: - Jonathan Cameron =20 -description: | - Ambient light and proximity sensor over an i2c interface. +description: + Ambient light and proximity sensor over an i2c interface. The STK36C61 + additionally provides RGBC colour channels. =20 allOf: - $ref: ../common.yaml# @@ -26,6 +26,7 @@ properties: - items: - enum: - sensortek,stk3013 + - sensortek,stk36c61 - const: sensortek,stk3310 =20 reg: --=20 2.55.0 From nobody Sat Sep 26 13:50:18 2026 Received: from out-2z4y-a134.jellyfish.systems (out-2z4y-a134.jellyfish.systems [198.54.127.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 96B7637F8B1 for ; Tue, 1 Sep 2026 00:52:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.54.127.134 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788223932; cv=none; b=J0MFSUi7fCg4j3X+CoGSm52KrRUORtdHKa0nHrFELHVk9aRvAWbDqzvefqbGpQ4ejveZ8bCuowfRJIcqf8tjSVUjorKbQTLkKfqCrQRf7/ccoTDIjAO91HeS+OiAPQdOuEWiMMq1JddKCEMmqWFB1oJdIbgiM+CORKUauLssowA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788223932; c=relaxed/simple; bh=ha+GSqVutmNsSLuP2U30alE19dKw12fjlDVUlAH1fhE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Cv2szc8NT3huDNJw8Fjbsudb85WiubPV1sDTl9YR0n+r4zj3pcbtixI6btdsdi0OlEX7JeHOfmvBx5jxbfD599Kd1DYEM0zEP+o3OCveGg2cnQdoqD58KPCSzG9VpZ0xNJZXKqUr7xxwQG2lMzPgApcgEExYQXwPPGA6Q3mdMYo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=catcrafts.net; spf=pass smtp.mailfrom=catcrafts.net; arc=none smtp.client-ip=198.54.127.134 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=catcrafts.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=catcrafts.net Received: from mail.privateemail.com (unknown [87.215.145.39]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.privateemail.com (Postfix) with ESMTPSA id 4hYnPK5LBRz2x9H; Tue, 01 Sep 2026 00:51:49 +0000 (UTC) From: Jorijn van der Graaf To: Jonathan Cameron , linux-iio@vger.kernel.org Cc: David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , Andy Shevchenko , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , devicetree@vger.kernel.org, Kees Cook , "Gustavo A . R . Silva" , linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, Luca Weiss , Marcelo Schmitt , Jorijn van der Graaf Subject: [PATCH v3 3/5] iio: light: stk3310: move the data registers into the channel address Date: Tue, 1 Sep 2026 02:51:12 +0200 Message-ID: <20260901005114.203062-4-jorijnvdgraaf@catcrafts.net> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260901005114.203062-1-jorijnvdgraaf@catcrafts.net> References: <20260901005114.203062-1-jorijnvdgraaf@catcrafts.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Envelope-From: jorijnvdgraaf@catcrafts.net Content-Type: text/plain; charset="utf-8" The RAW read selects its data register with a per-channel-type branch. Record each channel's data register in its .address field and read from there, so adding a channel does not grow the branch. Suggested-by: Jonathan Cameron Reviewed-by: Andy Shevchenko Assisted-by: Claude:claude-fable-5 Signed-off-by: Jorijn van der Graaf --- drivers/iio/light/stk3310.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/iio/light/stk3310.c b/drivers/iio/light/stk3310.c index 5b5b6812edc7..156888969366 100644 --- a/drivers/iio/light/stk3310.c +++ b/drivers/iio/light/stk3310.c @@ -184,6 +184,7 @@ static const struct iio_chan_spec_ext_info stk3310_ext_= info[] =3D { static const struct iio_chan_spec stk3310_channels[] =3D { { .type =3D IIO_LIGHT, + .address =3D STK3310_REG_ALS_DATA_MSB, .info_mask_separate =3D BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE) | @@ -191,6 +192,7 @@ static const struct iio_chan_spec stk3310_channels[] = =3D { }, { .type =3D IIO_PROXIMITY, + .address =3D STK3310_REG_PS_DATA_MSB, .info_mask_separate =3D BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE) | @@ -370,25 +372,20 @@ static int stk3310_read_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int *val, int *val2, long mask) { - u8 reg; __be16 buf; int ret; unsigned int index; struct stk3310_data *data =3D iio_priv(indio_dev); struct i2c_client *client =3D data->client; + struct regmap *map =3D data->regmap; =20 if (chan->type !=3D IIO_LIGHT && chan->type !=3D IIO_PROXIMITY) return -EINVAL; =20 switch (mask) { case IIO_CHAN_INFO_RAW: - if (chan->type =3D=3D IIO_LIGHT) - reg =3D STK3310_REG_ALS_DATA_MSB; - else - reg =3D STK3310_REG_PS_DATA_MSB; - mutex_lock(&data->lock); - ret =3D regmap_bulk_read(data->regmap, reg, &buf, sizeof(buf)); + ret =3D regmap_bulk_read(map, chan->address, &buf, sizeof(buf)); if (ret < 0) { dev_err(&client->dev, "register read failed\n"); mutex_unlock(&data->lock); --=20 2.55.0 From nobody Sat Sep 26 13:50:18 2026 Received: from out-2z4y-a139.jellyfish.systems (out-2z4y-a139.jellyfish.systems [198.54.127.139]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 38B5637C92C for ; Tue, 1 Sep 2026 00:52:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.54.127.139 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788223926; cv=none; b=VNmd4/zXT/l/0CtH6pIczdvCsLbhBFUypzoM+lAoBemePdTThAaa4QLW2pvsK0zgxedqv/6aEjkJKz/rtuQTl3ph3Y0cL3vINdTC/0HqUJ+9yQAOvb7SUqhW2EOcXtovqA5+NV/tbOYxOkkgiWhK2qqMdaXrDXseiXhtENJBi6g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788223926; c=relaxed/simple; bh=YyfYeRHPE5iyL2SILMlfMezha+RGEWGYlmgJuT5nyiY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DlXnl7i22dxsd/1zj8XSKWgysTMQlxhn6gm7uMe0ttSZeumRwis/FQPTd/vUDRVQsrlN2oLLBMm+Fw0q437U41Zyr2dBdEL8MDxONOpeq0lwYco32HwYGD8R6YT6wMEF63HiYiIdUbT8dqePAlGtbxKs9/FeKPybaHgMjlMxmHY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=catcrafts.net; spf=pass smtp.mailfrom=catcrafts.net; arc=none smtp.client-ip=198.54.127.139 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=catcrafts.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=catcrafts.net Received: from mail.privateemail.com (unknown [87.215.145.39]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.privateemail.com (Postfix) with ESMTPSA id 4hYnPQ0sHGz2x9C; Tue, 01 Sep 2026 00:51:53 +0000 (UTC) From: Jorijn van der Graaf To: Jonathan Cameron , linux-iio@vger.kernel.org Cc: David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , Andy Shevchenko , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , devicetree@vger.kernel.org, Kees Cook , "Gustavo A . R . Silva" , linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, Luca Weiss , Marcelo Schmitt , Jorijn van der Graaf Subject: [PATCH v3 4/5] iio: light: stk3310: add per-chip match data Date: Tue, 1 Sep 2026 02:51:13 +0200 Message-ID: <20260901005114.203062-5-jorijnvdgraaf@catcrafts.net> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260901005114.203062-1-jorijnvdgraaf@catcrafts.net> References: <20260901005114.203062-1-jorijnvdgraaf@catcrafts.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Envelope-From: jorijnvdgraaf@catcrafts.net Content-Type: text/plain; charset="utf-8" Introduce a chip_info structure carrying the device name and channel specification, attach it to every i2c, OF and ACPI table entry, and let probe take it from the match data, failing when there is none. Every firmware bind path carries match data, and with the id names in lower case a client instantiated through the sysfs new_device interface under the compatible's lower-case suffix receives it through the id table. The shared channel definitions move into macros. The ACPI table entries change to named initializers, matching the other id tables. This is a preparatory change for a variant that provides more channels than the existing parts. No functional change for firmware-described devices. A sysfs client under a name that binds without matching any id entry (the full compatible string) now fails probe with an error instead of probing as an stk3310. Assisted-by: Claude:claude-fable-5 Signed-off-by: Jorijn van der Graaf --- drivers/iio/light/stk3310.c | 95 ++++++++++++++++++++++++------------- 1 file changed, 61 insertions(+), 34 deletions(-) diff --git a/drivers/iio/light/stk3310.c b/drivers/iio/light/stk3310.c index 156888969366..f5782a1e19bb 100644 --- a/drivers/iio/light/stk3310.c +++ b/drivers/iio/light/stk3310.c @@ -181,26 +181,48 @@ static const struct iio_chan_spec_ext_info stk3310_ex= t_info[] =3D { { } }; =20 +#define STK3310_LIGHT_CHANNEL { \ + .type =3D IIO_LIGHT, \ + .address =3D STK3310_REG_ALS_DATA_MSB, \ + .info_mask_separate =3D \ + BIT(IIO_CHAN_INFO_RAW) | \ + BIT(IIO_CHAN_INFO_SCALE) | \ + BIT(IIO_CHAN_INFO_INT_TIME), \ +} + +#define STK3310_PROXIMITY_CHANNEL { \ + .type =3D IIO_PROXIMITY, \ + .address =3D STK3310_REG_PS_DATA_MSB, \ + .info_mask_separate =3D \ + BIT(IIO_CHAN_INFO_RAW) | \ + BIT(IIO_CHAN_INFO_SCALE) | \ + BIT(IIO_CHAN_INFO_INT_TIME), \ + .event_spec =3D stk3310_events, \ + .num_event_specs =3D ARRAY_SIZE(stk3310_events), \ + .ext_info =3D stk3310_ext_info, \ +} + static const struct iio_chan_spec stk3310_channels[] =3D { - { - .type =3D IIO_LIGHT, - .address =3D STK3310_REG_ALS_DATA_MSB, - .info_mask_separate =3D - BIT(IIO_CHAN_INFO_RAW) | - BIT(IIO_CHAN_INFO_SCALE) | - BIT(IIO_CHAN_INFO_INT_TIME), - }, - { - .type =3D IIO_PROXIMITY, - .address =3D STK3310_REG_PS_DATA_MSB, - .info_mask_separate =3D - BIT(IIO_CHAN_INFO_RAW) | - BIT(IIO_CHAN_INFO_SCALE) | - BIT(IIO_CHAN_INFO_INT_TIME), - .event_spec =3D stk3310_events, - .num_event_specs =3D ARRAY_SIZE(stk3310_events), - .ext_info =3D stk3310_ext_info, - } + STK3310_LIGHT_CHANNEL, + STK3310_PROXIMITY_CHANNEL, +}; + +/** + * struct stk3310_chip_info - chip-specific data + * @name: device name reported to the IIO core + * @channels: channel specification + * @num_channels: number of channels + */ +struct stk3310_chip_info { + const char *name; + const struct iio_chan_spec *channels __counted_by_ptr(num_channels); + unsigned int num_channels; +}; + +static const struct stk3310_chip_info stk3310_chip_info =3D { + .name =3D STK3310_DRIVER_NAME, + .channels =3D stk3310_channels, + .num_channels =3D ARRAY_SIZE(stk3310_channels), }; =20 static IIO_CONST_ATTR(in_illuminance_scale_available, STK3310_SCALE_AVAILA= BLE); @@ -632,10 +654,16 @@ static irqreturn_t stk3310_irq_event_handler(int irq,= void *private) =20 static int stk3310_probe(struct i2c_client *client) { + const struct stk3310_chip_info *chip_info; + struct device *dev =3D &client->dev; int ret; struct iio_dev *indio_dev; struct stk3310_data *data; =20 + chip_info =3D i2c_get_match_data(client); + if (!chip_info) + return dev_err_probe(dev, -ENODATA, "missing driver data\n"); + indio_dev =3D devm_iio_device_alloc(&client->dev, sizeof(*data)); if (!indio_dev) return -ENOMEM; @@ -654,10 +682,10 @@ static int stk3310_probe(struct i2c_client *client) return ret; =20 indio_dev->info =3D &stk3310_info; - indio_dev->name =3D STK3310_DRIVER_NAME; + indio_dev->name =3D chip_info->name; indio_dev->modes =3D INDIO_DIRECT_MODE; - indio_dev->channels =3D stk3310_channels; - indio_dev->num_channels =3D ARRAY_SIZE(stk3310_channels); + indio_dev->channels =3D chip_info->channels; + indio_dev->num_channels =3D chip_info->num_channels; =20 ret =3D stk3310_init(indio_dev); if (ret < 0) @@ -763,28 +791,27 @@ static DEFINE_SIMPLE_DEV_PM_OPS(stk3310_pm_ops, stk33= 10_suspend, stk3310_resume); =20 static const struct i2c_device_id stk3310_i2c_id[] =3D { - { .name =3D "stk3013" }, - { .name =3D "stk3310" }, - { .name =3D "stk3311" }, - { .name =3D "stk3335" }, + { .name =3D "stk3013", .driver_data =3D (kernel_ulong_t)&stk3310_chip_inf= o }, + { .name =3D "stk3310", .driver_data =3D (kernel_ulong_t)&stk3310_chip_inf= o }, + { .name =3D "stk3311", .driver_data =3D (kernel_ulong_t)&stk3310_chip_inf= o }, + { .name =3D "stk3335", .driver_data =3D (kernel_ulong_t)&stk3310_chip_inf= o }, { } }; MODULE_DEVICE_TABLE(i2c, stk3310_i2c_id); =20 static const struct acpi_device_id stk3310_acpi_id[] =3D { - {"STK3013", 0}, - {"STK3310", 0}, - {"STK3311", 0}, + { .id =3D "STK3013", .driver_data =3D (kernel_ulong_t)&stk3310_chip_info = }, + { .id =3D "STK3310", .driver_data =3D (kernel_ulong_t)&stk3310_chip_info = }, + { .id =3D "STK3311", .driver_data =3D (kernel_ulong_t)&stk3310_chip_info = }, { } }; - MODULE_DEVICE_TABLE(acpi, stk3310_acpi_id); =20 static const struct of_device_id stk3310_of_match[] =3D { - { .compatible =3D "sensortek,stk3013", }, - { .compatible =3D "sensortek,stk3310", }, - { .compatible =3D "sensortek,stk3311", }, - { .compatible =3D "sensortek,stk3335", }, + { .compatible =3D "sensortek,stk3013", .data =3D &stk3310_chip_info }, + { .compatible =3D "sensortek,stk3310", .data =3D &stk3310_chip_info }, + { .compatible =3D "sensortek,stk3311", .data =3D &stk3310_chip_info }, + { .compatible =3D "sensortek,stk3335", .data =3D &stk3310_chip_info }, { } }; MODULE_DEVICE_TABLE(of, stk3310_of_match); --=20 2.55.0 From nobody Sat Sep 26 13:50:18 2026 Received: from out-2uec-a94.jellyfish.systems (out-2uec-a94.jellyfish.systems [63.250.43.94]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1837B37DEB7 for ; Tue, 1 Sep 2026 00:52:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=63.250.43.94 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788223930; cv=none; b=MQL+FUl6pb+IaUB9rAqUDxapODPFPUTyWdAEAh0P637quiEJxQffkGm++YxxUF0O3I91kopojfYARRNg3bbeQZs7k4oK6j+SAy/Git7DDv71QG5mFvRRtULhAVgmFP853fz0ktErxVizVaXn2ZWgSSc7MiTPYdIRcIc2KuyOWOk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788223930; c=relaxed/simple; bh=Qz7Zxt5XRekgabE4gfhDyrP59snWbTlwpwIyvAO6zSM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HYv+aHgBspa++Q+92oMbK0NOVoS7ruLFCDANiX0qqi9APYF0DaqQ+ez+CxnOozRLisvYbTkl6O/rbVbA57tycBYSypZwsLQOjDyhzREJ86QPXbDYJFP9HWXp+fVnHumsbaAWyhfVTKLW4t05c7MW0X4WnVYzLzP/2zM5PA8UnAU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=catcrafts.net; spf=pass smtp.mailfrom=catcrafts.net; arc=none smtp.client-ip=63.250.43.94 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=catcrafts.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=catcrafts.net Received: from mail.privateemail.com (unknown [87.215.145.39]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.privateemail.com (Postfix) with ESMTPSA id 4hYnPV3Qmxz2x9D; Tue, 01 Sep 2026 00:51:58 +0000 (UTC) From: Jorijn van der Graaf To: Jonathan Cameron , linux-iio@vger.kernel.org Cc: David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , Andy Shevchenko , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , devicetree@vger.kernel.org, Kees Cook , "Gustavo A . R . Silva" , linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, Luca Weiss , Marcelo Schmitt , Jorijn van der Graaf Subject: [PATCH v3 5/5] iio: light: stk3310: support the Sensortek STK36C61 Date: Tue, 1 Sep 2026 02:51:14 +0200 Message-ID: <20260901005114.203062-6-jorijnvdgraaf@catcrafts.net> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260901005114.203062-1-jorijnvdgraaf@catcrafts.net> References: <20260901005114.203062-1-jorijnvdgraaf@catcrafts.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Envelope-From: jorijnvdgraaf@catcrafts.net Content-Type: text/plain; charset="utf-8" The Sensortek STK36C61 is a 3-in-1 ambient light / proximity / RGB colour sensor. Its register interface is compatible with the feature set this driver uses. Add its chip ID to the known-ID list and the device table entries. Whenever the ALS engine runs, the chip also measures four colour channels: red, green, blue and clear, laid out directly after the ALS data as 16-bit big-endian values. R, G and B are gained by the same ALSCTRL gain field the illuminance channel uses, clear by its own gain field in the GAINCTRL register, and the whole colour block integrates over the ALS integration time. Expose the channels with per-channel scale and a shared integration time, as suggested by Jonathan Cameron for the green channel. The scales reuse the driver's existing gain-only table: green equals the ALS data, so its scale must read identically to the pre-existing in_illuminance_scale. Assisted-by: Claude:claude-fable-5 Signed-off-by: Jorijn van der Graaf --- Documentation/ABI/testing/sysfs-bus-iio | 1 + drivers/iio/light/stk3310.c | 101 ++++++++++++++++++++---- 2 files changed, 88 insertions(+), 14 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/te= sting/sysfs-bus-iio index a4f5595722ad..08a8de215814 100644 --- a/Documentation/ABI/testing/sysfs-bus-iio +++ b/Documentation/ABI/testing/sysfs-bus-iio @@ -507,6 +507,7 @@ What: /sys/bus/iio/devices/iio:deviceX/in_intensity_z_= scale What: /sys/bus/iio/devices/iio:deviceX/in_intensity_red_scale What: /sys/bus/iio/devices/iio:deviceX/in_intensity_green_scale What: /sys/bus/iio/devices/iio:deviceX/in_intensity_blue_scale +What: /sys/bus/iio/devices/iio:deviceX/in_intensity_clear_scale What: /sys/bus/iio/devices/iio:deviceX/in_concentration_co2_scale What: /sys/bus/iio/devices/iio:deviceX/in_volumeflow_scale What: /sys/bus/iio/devices/iio:deviceX/in_volumeflowY_scale diff --git a/drivers/iio/light/stk3310.c b/drivers/iio/light/stk3310.c index f5782a1e19bb..0a16e326e939 100644 --- a/drivers/iio/light/stk3310.c +++ b/drivers/iio/light/stk3310.c @@ -40,7 +40,13 @@ #define STK3310_REG_PS_DATA_LSB 0x12 #define STK3310_REG_ALS_DATA_MSB 0x13 #define STK3310_REG_ALS_DATA_LSB 0x14 +#define STK36C61_REG_RED_DATA_MSB 0x15 +#define STK36C61_REG_GREEN_DATA_MSB 0x17 +#define STK36C61_REG_BLUE_DATA_MSB 0x19 +#define STK36C61_REG_CLEAR_DATA_MSB 0x1B +#define STK36C61_REG_CLEAR_DATA_LSB 0x1C #define STK3310_REG_ID 0x3E +#define STK36C61_REG_GAINCTRL 0x4E #define STK3310_MAX_REG 0x80 =20 #define STK3310_STATE_EN_PS BIT(0) @@ -54,6 +60,7 @@ #define STK3311S34_CHIP_ID_VAL 0x1E #define STK3311X_CHIP_ID_VAL 0x12 #define STK3335_CHIP_ID_VAL 0x51 +#define STK36C61_CHIP_ID_VAL 0x95 #define STK3310_PSINT_EN 0x01 #define STK3310_PS_MAX_VAL 0xFFFF =20 @@ -83,6 +90,8 @@ static const struct reg_field stk3310_reg_field_als_gain = =3D REG_FIELD(STK3310_REG_ALSCTRL, 4, 5); static const struct reg_field stk3310_reg_field_ps_gain =3D REG_FIELD(STK3310_REG_PSCTRL, 4, 5); +static const struct reg_field stk3310_reg_field_clear_gain =3D + REG_FIELD(STK36C61_REG_GAINCTRL, 4, 5); static const struct reg_field stk3310_reg_field_als_it =3D REG_FIELD(STK3310_REG_ALSCTRL, 0, 3); static const struct reg_field stk3310_reg_field_ps_it =3D @@ -102,6 +111,7 @@ static const u8 stk3310_chip_ids[] =3D { STK3311X_CHIP_ID_VAL, STK3311_CHIP_ID_VAL, STK3335_CHIP_ID_VAL, + STK36C61_CHIP_ID_VAL, }; =20 /* Estimate maximum proximity values with regard to measurement scale. */ @@ -132,6 +142,7 @@ struct stk3310_data { struct regmap_field *reg_state; struct regmap_field *reg_als_gain; struct regmap_field *reg_ps_gain; + struct regmap_field *reg_clear_gain; struct regmap_field *reg_als_it; struct regmap_field *reg_ps_it; struct regmap_field *reg_int_ps; @@ -202,11 +213,35 @@ static const struct iio_chan_spec_ext_info stk3310_ex= t_info[] =3D { .ext_info =3D stk3310_ext_info, \ } =20 +#define STK36C61_INTENSITY_CHANNEL(_mod, _reg) { \ + .type =3D IIO_INTENSITY, \ + .address =3D _reg, \ + .modified =3D 1, \ + .channel2 =3D IIO_MOD_LIGHT_##_mod, \ + .info_mask_separate =3D \ + BIT(IIO_CHAN_INFO_RAW) | \ + BIT(IIO_CHAN_INFO_SCALE), \ + .info_mask_shared_by_type =3D \ + BIT(IIO_CHAN_INFO_INT_TIME), \ + .info_mask_shared_by_type_available =3D \ + BIT(IIO_CHAN_INFO_SCALE) | \ + BIT(IIO_CHAN_INFO_INT_TIME), \ +} + static const struct iio_chan_spec stk3310_channels[] =3D { STK3310_LIGHT_CHANNEL, STK3310_PROXIMITY_CHANNEL, }; =20 +static const struct iio_chan_spec stk36c61_channels[] =3D { + STK3310_LIGHT_CHANNEL, + STK3310_PROXIMITY_CHANNEL, + STK36C61_INTENSITY_CHANNEL(RED, STK36C61_REG_RED_DATA_MSB), + STK36C61_INTENSITY_CHANNEL(GREEN, STK36C61_REG_GREEN_DATA_MSB), + STK36C61_INTENSITY_CHANNEL(BLUE, STK36C61_REG_BLUE_DATA_MSB), + STK36C61_INTENSITY_CHANNEL(CLEAR, STK36C61_REG_CLEAR_DATA_MSB), +}; + /** * struct stk3310_chip_info - chip-specific data * @name: device name reported to the IIO core @@ -225,6 +260,12 @@ static const struct stk3310_chip_info stk3310_chip_inf= o =3D { .num_channels =3D ARRAY_SIZE(stk3310_channels), }; =20 +static const struct stk3310_chip_info stk36c61_chip_info =3D { + .name =3D "stk36c61", + .channels =3D stk36c61_channels, + .num_channels =3D ARRAY_SIZE(stk36c61_channels), +}; + static IIO_CONST_ATTR(in_illuminance_scale_available, STK3310_SCALE_AVAILA= BLE); =20 static IIO_CONST_ATTR(in_proximity_scale_available, STK3310_SCALE_AVAILABL= E); @@ -401,7 +442,8 @@ static int stk3310_read_raw(struct iio_dev *indio_dev, struct i2c_client *client =3D data->client; struct regmap *map =3D data->regmap; =20 - if (chan->type !=3D IIO_LIGHT && chan->type !=3D IIO_PROXIMITY) + if (chan->type !=3D IIO_LIGHT && chan->type !=3D IIO_PROXIMITY && + chan->type !=3D IIO_INTENSITY) return -EINVAL; =20 switch (mask) { @@ -417,10 +459,10 @@ static int stk3310_read_raw(struct iio_dev *indio_dev, mutex_unlock(&data->lock); return IIO_VAL_INT; case IIO_CHAN_INFO_INT_TIME: - if (chan->type =3D=3D IIO_LIGHT) - ret =3D regmap_field_read(data->reg_als_it, &index); - else + if (chan->type =3D=3D IIO_PROXIMITY) ret =3D regmap_field_read(data->reg_ps_it, &index); + else + ret =3D regmap_field_read(data->reg_als_it, &index); if (ret < 0) return ret; =20 @@ -428,10 +470,12 @@ static int stk3310_read_raw(struct iio_dev *indio_dev, *val2 =3D stk3310_it_table[index][1]; return IIO_VAL_INT_PLUS_MICRO; case IIO_CHAN_INFO_SCALE: - if (chan->type =3D=3D IIO_LIGHT) - ret =3D regmap_field_read(data->reg_als_gain, &index); - else + if (chan->type =3D=3D IIO_PROXIMITY) ret =3D regmap_field_read(data->reg_ps_gain, &index); + else if (chan->channel2 =3D=3D IIO_MOD_LIGHT_CLEAR) + ret =3D regmap_field_read(data->reg_clear_gain, &index); + else + ret =3D regmap_field_read(data->reg_als_gain, &index); if (ret < 0) return ret; =20 @@ -451,7 +495,8 @@ static int stk3310_write_raw(struct iio_dev *indio_dev, int index; struct stk3310_data *data =3D iio_priv(indio_dev); =20 - if (chan->type !=3D IIO_LIGHT && chan->type !=3D IIO_PROXIMITY) + if (chan->type !=3D IIO_LIGHT && chan->type !=3D IIO_PROXIMITY && + chan->type !=3D IIO_INTENSITY) return -EINVAL; =20 switch (mask) { @@ -462,10 +507,10 @@ static int stk3310_write_raw(struct iio_dev *indio_de= v, if (index < 0) return -EINVAL; mutex_lock(&data->lock); - if (chan->type =3D=3D IIO_LIGHT) - ret =3D regmap_field_write(data->reg_als_it, index); - else + if (chan->type =3D=3D IIO_PROXIMITY) ret =3D regmap_field_write(data->reg_ps_it, index); + else + ret =3D regmap_field_write(data->reg_als_it, index); if (ret < 0) dev_err(&data->client->dev, "sensor configuration failed\n"); @@ -479,10 +524,12 @@ static int stk3310_write_raw(struct iio_dev *indio_de= v, if (index < 0) return -EINVAL; mutex_lock(&data->lock); - if (chan->type =3D=3D IIO_LIGHT) - ret =3D regmap_field_write(data->reg_als_gain, index); - else + if (chan->type =3D=3D IIO_PROXIMITY) ret =3D regmap_field_write(data->reg_ps_gain, index); + else if (chan->channel2 =3D=3D IIO_MOD_LIGHT_CLEAR) + ret =3D regmap_field_write(data->reg_clear_gain, index); + else + ret =3D regmap_field_write(data->reg_als_gain, index); if (ret < 0) dev_err(&data->client->dev, "sensor configuration failed\n"); @@ -493,9 +540,31 @@ static int stk3310_write_raw(struct iio_dev *indio_dev, return -EINVAL; } =20 +static int stk3310_read_avail(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + const int **vals, int *type, int *length, + long mask) +{ + switch (mask) { + case IIO_CHAN_INFO_SCALE: + *vals =3D (const int *)stk3310_scale_table; + *length =3D 2 * ARRAY_SIZE(stk3310_scale_table); + *type =3D IIO_VAL_INT_PLUS_MICRO; + return IIO_AVAIL_LIST; + case IIO_CHAN_INFO_INT_TIME: + *vals =3D (const int *)stk3310_it_table; + *length =3D 2 * ARRAY_SIZE(stk3310_it_table); + *type =3D IIO_VAL_INT_PLUS_MICRO; + return IIO_AVAIL_LIST; + default: + return -EINVAL; + } +} + static const struct iio_info stk3310_info =3D { .read_raw =3D stk3310_read_raw, .write_raw =3D stk3310_write_raw, + .read_avail =3D stk3310_read_avail, .attrs =3D &stk3310_attribute_group, .read_event_value =3D stk3310_read_event, .write_event_value =3D stk3310_write_event, @@ -567,6 +636,7 @@ static bool stk3310_is_volatile_reg(struct device *dev,= unsigned int reg) switch (reg) { case STK3310_REG_ALS_DATA_MSB: case STK3310_REG_ALS_DATA_LSB: + case STK36C61_REG_RED_DATA_MSB ... STK36C61_REG_CLEAR_DATA_LSB: case STK3310_REG_PS_DATA_LSB: case STK3310_REG_PS_DATA_MSB: case STK3310_REG_FLAG: @@ -601,6 +671,7 @@ static int stk3310_regmap_init(struct stk3310_data *dat= a) STK3310_REGFIELD(state); STK3310_REGFIELD(als_gain); STK3310_REGFIELD(ps_gain); + STK3310_REGFIELD(clear_gain); STK3310_REGFIELD(als_it); STK3310_REGFIELD(ps_it); STK3310_REGFIELD(int_ps); @@ -795,6 +866,7 @@ static const struct i2c_device_id stk3310_i2c_id[] =3D { { .name =3D "stk3310", .driver_data =3D (kernel_ulong_t)&stk3310_chip_inf= o }, { .name =3D "stk3311", .driver_data =3D (kernel_ulong_t)&stk3310_chip_inf= o }, { .name =3D "stk3335", .driver_data =3D (kernel_ulong_t)&stk3310_chip_inf= o }, + { .name =3D "stk36c61", .driver_data =3D (kernel_ulong_t)&stk36c61_chip_i= nfo }, { } }; MODULE_DEVICE_TABLE(i2c, stk3310_i2c_id); @@ -812,6 +884,7 @@ static const struct of_device_id stk3310_of_match[] =3D= { { .compatible =3D "sensortek,stk3310", .data =3D &stk3310_chip_info }, { .compatible =3D "sensortek,stk3311", .data =3D &stk3310_chip_info }, { .compatible =3D "sensortek,stk3335", .data =3D &stk3310_chip_info }, + { .compatible =3D "sensortek,stk36c61", .data =3D &stk36c61_chip_info }, { } }; MODULE_DEVICE_TABLE(of, stk3310_of_match); --=20 2.55.0