From nobody Tue Sep 29 09:09:42 2026 Received: from out-2z4y-a149.jellyfish.systems (out-2z4y-a149.jellyfish.systems [198.54.127.149]) (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 89115356744 for ; Mon, 10 Aug 2026 11:17:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.54.127.149 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786360640; cv=none; b=YH8iOzINUS8AcNG107q0XGkSllKTk9gaXsrhVKhLHbjO1GYza4cs4LZeVmwJ53LwJwFOr9p0o9Zl31WzpbshZkmvqRt14g3DM7JBW05n7ori2BCZXzY30NgF81Z2zuKbq+hdltqqo6Q2p5p8kaRLeO//gCDjBUpvLBLhS75UZo0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786360640; c=relaxed/simple; bh=3Y1xMEOAwH1QMRI4pDjeFz63XQW/IskcSv3+UqwmQZs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UCKE3zWmerAn88YjlxeHym2dtOBLw+uxC0Rxd6VCYvyiGM/saBZrX3UMjkiGYPxKxSL4EJFjeNIVPszY4zSWROwfOdrfaRDVzky8D0umGiY0XMCAqU6fTHmj5Gmi9/TKMTX/8K7XnOJT8wuMUm5mLkUxOsGVrW7fuZfQscyoLjU= 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.149 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 4hJX2Z4Y18z8sWQ; Mon, 10 Aug 2026 11:04:38 +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 , 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 , Jorijn van der Graaf Subject: [PATCH 1/3] dt-bindings: iio: light: stk33xx: document the Sensortek STK36C61 Date: Mon, 10 Aug 2026 13:04:21 +0200 Message-ID: <20260810110423.41697-2-jorijnvdgraaf@catcrafts.net> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260810110423.41697-1-jorijnvdgraaf@catcrafts.net> References: <20260810110423.41697-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. Assisted-by: Claude:claude-fable-5 Signed-off-by: Jorijn van der Graaf Reviewed-by: Krzysztof Kozlowski --- 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 Tue Sep 29 09:09:42 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 891B239CCFE for ; Mon, 10 Aug 2026 11:17:19 +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=1786360641; cv=none; b=L434NKu0nSl4BfmwkRNoTZ8/0+hhXmgX2NfkbuPUvusk3ndiyJYPn3U5pXOWnIN93XFQcfLANJmrc/GZ533BzVNzc/CEjUodpgRihqr+fvCJ2+871lBw9vrcvZQmBgtgxLqwW+/UEXhsQi7l25C5dy7vqjyvvJGLub4RrSWuCxM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786360641; c=relaxed/simple; bh=sBvM+tDWMz5O+hEmeCj8uf9pMYKp0SvqXvWOJDd2SQE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bEfBQB4lv29iJFcQNFGWtaAKk2erZc60xvY7qRBymq6x7cpGNd4cKRI/f1K2Om+XEVCPuUvoDurKZc0phJ5H565bMG4TnRB9Tt8IfksYzaRzweplPwtMY0e/1+7KBDdmh/i7VytEvif5pf/oqfSi2WbGmAzNGNQN+art998zU7w= 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 4hJX2f5Tmmz8sWP; Mon, 10 Aug 2026 11:04:42 +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 , 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 , Jorijn van der Graaf Subject: [PATCH 2/3] iio: light: stk3310: add per-chip match data Date: Mon, 10 Aug 2026 13:04:22 +0200 Message-ID: <20260810110423.41697-3-jorijnvdgraaf@catcrafts.net> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260810110423.41697-1-jorijnvdgraaf@catcrafts.net> References: <20260810110423.41697-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. Clients instantiated through the sysfs new_device interface under the lowercase compatible-derived name have no firmware node and do not match the uppercase id table entries, so absent match data falls back to the original chip data. The channel data registers move into .address and the shared channel definitions into macros. This is a preparatory change for a variant that provides more channels than the existing parts. No functional change. Assisted-by: Claude:claude-fable-5 Signed-off-by: Jorijn van der Graaf --- drivers/iio/light/stk3310.c | 107 +++++++++++++++++++++++------------- 1 file changed, 69 insertions(+), 38 deletions(-) diff --git a/drivers/iio/light/stk3310.c b/drivers/iio/light/stk3310.c index 7c8a1d2b2ed0..249396b9bf80 100644 --- a/drivers/iio/light/stk3310.c +++ b/drivers/iio/light/stk3310.c @@ -181,24 +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, - .info_mask_separate =3D - BIT(IIO_CHAN_INFO_RAW) | - BIT(IIO_CHAN_INFO_SCALE) | - BIT(IIO_CHAN_INFO_INT_TIME), - }, - { - .type =3D IIO_PROXIMITY, - .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); @@ -370,7 +394,6 @@ 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; @@ -382,13 +405,9 @@ static int stk3310_read_raw(struct iio_dev *indio_dev, =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(data->regmap, chan->address, &buf, + sizeof(buf)); if (ret < 0) { dev_err(&client->dev, "register read failed\n"); mutex_unlock(&data->lock); @@ -635,10 +654,22 @@ 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; int ret; struct iio_dev *indio_dev; struct stk3310_data *data; =20 + chip_info =3D i2c_get_match_data(client); + if (!chip_info) { + /* + * Clients instantiated through the sysfs new_device + * interface under the lowercase compatible-derived name + * have no firmware node and do not match the uppercase + * id table entries. + */ + chip_info =3D &stk3310_chip_info; + } + indio_dev =3D devm_iio_device_alloc(&client->dev, sizeof(*data)); if (!indio_dev) return -ENOMEM; @@ -657,10 +688,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) @@ -766,28 +797,28 @@ 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}, + {"STK3013", (kernel_ulong_t)&stk3310_chip_info}, + {"STK3310", (kernel_ulong_t)&stk3310_chip_info}, + {"STK3311", (kernel_ulong_t)&stk3310_chip_info}, { } }; =20 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 Tue Sep 29 09:09:42 2026 Received: from out-93wp-a23.jellyfish.systems (out-93wp-a23.jellyfish.systems [104.207.68.23]) (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 D785C3BC69D for ; Mon, 10 Aug 2026 11:10:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=104.207.68.23 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786360217; cv=none; b=M8XczSlIUyXJZ79lpkoWMH89dbKQj0CEp4zkPvgW6KvnFb3WreJv55RWzkXvCVUjG59IF2ZC9VGCg34GqwmRVPw/v6W+nNDkmYtTPFN5H63ZAgWyqhKHZuvsGxlToW27HomvMyY2iBjqDuuSWgifnfRVao4wkvTiKLNQ+fCT5ao= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786360217; c=relaxed/simple; bh=bwjCD43E9bjMXAxChdrLhk7PINHWYkrOck/9FWTc4F8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CxXagpDobN6YD4aO43xNsnKJTjDFlwEsSLeOLuWhcDp3EzRcA9L+DMJEep7o2hy5WgN3QLAAhB0syNWeAYB6i5jfRAc/z2bHzzHUSwX2VMVq9we6imQohWdAeq/x4cosf239DKiBAP+25QIP1M84BLq4WN1j5jzEs/LfHqV3Qfs= 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=104.207.68.23 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 4hJX2k6PYnz8sWQ; Mon, 10 Aug 2026 11:04:46 +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 , 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 , Jorijn van der Graaf Subject: [PATCH 3/3] iio: light: stk3310: support the Sensortek STK36C61 Date: Mon, 10 Aug 2026 13:04:23 +0200 Message-ID: <20260810110423.41697-4-jorijnvdgraaf@catcrafts.net> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260810110423.41697-1-jorijnvdgraaf@catcrafts.net> References: <20260810110423.41697-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 (chip ID 0x95) found in the Fairphone 6. Its register interface is compatible with the feature set this driver uses: the STATE/FLAG bit layout, the data and threshold registers and the gain and integration-time fields, verified on that device (the ALS and proximity readings scale with their gain and integration-time fields, thresholds written through the event interface read back from the chip, and the FLAG near/far bit crosses with them). 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, laid out directly after the ALS data as 16-bit big-endian values in R (0x15), G (0x17), B (0x19), C (0x1B) order; the R, G and B assignments were each confirmed by the matching channel dominating under red, green and blue illumination, and clear by its broadband response. The ALS data register tracks the green channel exactly. There is no public datasheet and therefore no counts-to-physical mapping for the colour channels, so they are exposed as raw-only intensity channels; the gain field the scale attribute controls does not govern clear either. Assisted-by: Claude:claude-fable-5 Signed-off-by: Jorijn van der Graaf --- drivers/iio/light/stk3310.c | 44 ++++++++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 3 deletions(-) diff --git a/drivers/iio/light/stk3310.c b/drivers/iio/light/stk3310.c index 249396b9bf80..288b544a8abb 100644 --- a/drivers/iio/light/stk3310.c +++ b/drivers/iio/light/stk3310.c @@ -40,6 +40,11 @@ #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 STK3310_MAX_REG 0x80 =20 @@ -54,6 +59,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 @@ -102,6 +108,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. */ @@ -202,11 +209,28 @@ 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, \ + .modified =3D 1, \ + .channel2 =3D IIO_MOD_LIGHT_##_mod, \ + .info_mask_separate =3D BIT(IIO_CHAN_INFO_RAW), \ + .address =3D _reg, \ +} + 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 +249,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); @@ -400,7 +430,8 @@ static int stk3310_read_raw(struct iio_dev *indio_dev, struct stk3310_data *data =3D iio_priv(indio_dev); struct i2c_client *client =3D data->client; =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) { @@ -419,8 +450,10 @@ static int stk3310_read_raw(struct iio_dev *indio_dev, case IIO_CHAN_INFO_INT_TIME: if (chan->type =3D=3D IIO_LIGHT) ret =3D regmap_field_read(data->reg_als_it, &index); - else + else if (chan->type =3D=3D IIO_PROXIMITY) ret =3D regmap_field_read(data->reg_ps_it, &index); + else + return -EINVAL; if (ret < 0) return ret; =20 @@ -430,8 +463,10 @@ static int stk3310_read_raw(struct iio_dev *indio_dev, case IIO_CHAN_INFO_SCALE: if (chan->type =3D=3D IIO_LIGHT) ret =3D regmap_field_read(data->reg_als_gain, &index); - else + else if (chan->type =3D=3D IIO_PROXIMITY) ret =3D regmap_field_read(data->reg_ps_gain, &index); + else + return -EINVAL; if (ret < 0) return ret; =20 @@ -567,6 +602,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: @@ -801,6 +837,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); @@ -819,6 +856,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