Linux IIO development
 help / color / mirror / Atom feed
* [PATCH v3] iio: light: cm32181: add support for the CM32183
@ 2026-10-13 15:07 Zixin Wang
  2026-10-13 21:21 ` Andy Shevchenko
  0 siblings, 1 reply; 3+ messages in thread
From: Zixin Wang @ 2026-10-13 15:07 UTC (permalink / raw)
  To: Kevin Tsai, Jonathan Cameron
  Cc: linux-iio, David Lechner, Nuno Sá, Andy Shevchenko,
	Joshua Crofts

From: Zixin Wang <ywp1023456@foxmail.com>
Date: Sun, 11 Oct 2026 08:29:13 +0000
Subject: [PATCH v3] iio: light: cm32181: add support for the CM32183

Add the device ID for the CM32183. The device has the same register
layout as the CM32181. Found on the H3C MegaBook 14.

Datasheet: http://www.capellamicro.com.tw/EN/product_c.php?id=96&mode=14
Signed-off-by: Zixin Wang <ywp1023456@foxmail.com>
---
v3:
- Reformat the CPM0 comment as suggested by Andy Shevchenko.
- Mention the product this part is found on, as suggested by Andy
  Shevchenko.
- Add a Datasheet: tag as suggested by Joshua Crofts. The CM32183
  datasheet is only offered by the vendor after registering a My Capella
  account, and no publicly downloadable copy could be found, so the tag
  points at the public product page for the part.

v1: https://lore.kernel.org/linux-iio/tencent_C2E579008244A394105247CCC4787391C209@qq.com/

The CM32183 is another member of the Capella CM3218x ambient light
sensor family. Its device ID register (0x07) returns 0x83 in the low
byte, following the same scheme as the already supported parts:

    CM3218  -> 0x18
    CM32181 -> 0x81
    CM32182 -> 0x82
    CM32183 -> 0x83

The driver falls through to the default branch of the ID switch and
returns -ENODEV, so probe() fails even though the device is present and
functional:

    cm32181 i2c-CPLM3218:00: cm32181_probe: register init failed

This was observed on an H3C MegaBook 14 (Intel Core Ultra 5 226V, Lunar
Lake). Its DSDT declares the sensor as:

    Device (LSRD) {
        Name (_HID, "CPLM3218")
        Name (_CID, "CPLM3218")
        Name (_UID, 1)
    }

on I2C at address 0x29, and additionally provides the vendor
initialisation and calibration objects that this driver already parses.
CPM0[0] reports a device-id of 32183, and CPM1 provides lux_per_bit =
2200 and calibscale = 265859.

Treat the CM32183 like the CM32181.

Measurements on the above machine confirm the register layout matches:
the power-on value of the CMD register (0x0001) has bit 0 set, which is
CM32181_CMD_ALS_DISABLE, and register 0x04 is the ALS data register.
With this change the driver binds, the ACPI-provided initialisation
values are written and the CPM1 calibration is taken into account
(in_illuminance_calibscale reads back 265859). The reported illuminance
tracks ambient light without saturating.

Please Cc me on replies, I am not subscribed to linux-iio.
---
 drivers/iio/light/cm32181.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/light/cm32181.c b/drivers/iio/light/cm32181.c
index 2590fc8..ac6ec6f 100644
--- a/drivers/iio/light/cm32181.c
+++ b/drivers/iio/light/cm32181.c
@@ -54,7 +54,12 @@
 
 #define SMBUS_ALERT_RESPONSE_ADDRESS	0x0c
 
-/* CPM0 Index 0: device-id (3218 or 32181), 1: Unknown, 2: init_regs_bitmap */
+/*
+ * CPM0 Index
+ * 0: device-id (3218, 32181, or 32183),
+ * 1: Unknown,
+ * 2: init_regs_bitmap
+ */
 #define CPM0_REGS_BITMAP		2
 #define CPM0_HEADER_SIZE		3
 
@@ -200,6 +205,7 @@ static int cm32181_reg_init(struct cm32181_chip *cm32181)
 		break;
 	case 0x81: /* CM32181 */
 	case 0x82: /* CM32182, fully compat. with CM32181 */
+	case 0x83: /* CM32183 */
 		cm32181->num_als_it = ARRAY_SIZE(cm32181_als_it_bits);
 		cm32181->als_it_bits = cm32181_als_it_bits;
 		cm32181->als_it_values = cm32181_als_it_values;
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v3] iio: light: cm32181: add support for the CM32183
  2026-10-13 15:07 [PATCH v3] iio: light: cm32181: add support for the CM32183 Zixin Wang
@ 2026-10-13 21:21 ` Andy Shevchenko
  2026-10-15 20:24   ` Joshua Crofts
  0 siblings, 1 reply; 3+ messages in thread
From: Andy Shevchenko @ 2026-10-13 21:21 UTC (permalink / raw)
  To: Zixin Wang
  Cc: Kevin Tsai, Jonathan Cameron, linux-iio, David Lechner,
	Nuno Sá, Andy Shevchenko, Joshua Crofts

On Tue, Oct 13, 2026 at 11:07:30PM +0800, Zixin Wang wrote:
> From: Zixin Wang <ywp1023456@foxmail.com>
> Date: Sun, 11 Oct 2026 08:29:13 +0000
> Subject: [PATCH v3] iio: light: cm32181: add support for the CM32183
> 
> Add the device ID for the CM32183. The device has the same register
> layout as the CM32181. Found on the H3C MegaBook 14.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>

However I dunno if the above email tags will be handled correctly by the tools
(usually we don't have double Date and Subject email headers).

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v3] iio: light: cm32181: add support for the CM32183
  2026-10-13 21:21 ` Andy Shevchenko
@ 2026-10-15 20:24   ` Joshua Crofts
  0 siblings, 0 replies; 3+ messages in thread
From: Joshua Crofts @ 2026-10-15 20:24 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Zixin Wang, Kevin Tsai, Jonathan Cameron, linux-iio,
	David Lechner, Nuno Sá, Andy Shevchenko

On Wed, 14 Oct 2026 00:21:00 +0300
Andy Shevchenko <andriy.shevchenko@intel.com> wrote:

> On Tue, Oct 13, 2026 at 11:07:30PM +0800, Zixin Wang wrote:
> > From: Zixin Wang <ywp1023456@foxmail.com>
> > Date: Sun, 11 Oct 2026 08:29:13 +0000
> > Subject: [PATCH v3] iio: light: cm32181: add support for the CM32183
> > 
> > Add the device ID for the CM32183. The device has the same register
> > layout as the CM32181. Found on the H3C MegaBook 14.  
> 
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
> 
> However I dunno if the above email tags will be handled correctly by the tools
> (usually we don't have double Date and Subject email headers).
> 

I checked just in case and b4 ignores these and applies the patch
successfully (while retaining your Rb tag).

-- 
Kind regards,
Joshua Crofts

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-10-15 20:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-13 15:07 [PATCH v3] iio: light: cm32181: add support for the CM32183 Zixin Wang
2026-10-13 21:21 ` Andy Shevchenko
2026-10-15 20:24   ` Joshua Crofts

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox