Linux IIO development
 help / color / mirror / Atom feed
* [PATCH v2] iio: light: cm32181: add support for the CM32183
@ 2026-10-11 17:02 Zixin Wang
  2026-10-11 17:31 ` Joshua Crofts
  2026-10-12 21:21 ` Andy Shevchenko
  0 siblings, 2 replies; 4+ messages in thread
From: Zixin Wang @ 2026-10-11 17:02 UTC (permalink / raw)
  To: Kevin Tsai, Jonathan Cameron
  Cc: linux-iio, David Lechner, Nuno Sá, Andy Shevchenko,
	Joshua Crofts

Add the device ID for the CM32183. The device has the same register
layout as the CM32181.

Signed-off-by: Zixin Wang <ywp1023456@foxmail.com>
---
v2:
- Shorten the commit message and move the detailed rationale below the
  fold, as suggested by Joshua Crofts.

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 | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/light/cm32181.c b/drivers/iio/light/cm32181.c
index 2590fc8..97882e4 100644
--- a/drivers/iio/light/cm32181.c
+++ b/drivers/iio/light/cm32181.c
@@ -54,7 +54,10 @@
 
 #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 +203,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] 4+ messages in thread

* Re: [PATCH v2] iio: light: cm32181: add support for the CM32183
  2026-10-11 17:02 [PATCH v2] iio: light: cm32181: add support for the CM32183 Zixin Wang
@ 2026-10-11 17:31 ` Joshua Crofts
  2026-10-11 18:23   ` Zixin Wang
  2026-10-12 21:21 ` Andy Shevchenko
  1 sibling, 1 reply; 4+ messages in thread
From: Joshua Crofts @ 2026-10-11 17:31 UTC (permalink / raw)
  To: Zixin Wang
  Cc: Kevin Tsai, Jonathan Cameron, linux-iio, David Lechner,
	Nuno Sá, Andy Shevchenko

On Sun, 11 Oct 2026 17:02:57 +0000 (UTC)
Zixin Wang <ywp1023456@foxmail.com> wrote:

> Add the device ID for the CM32183. The device has the same register
> layout as the CM32181.
> 
> Signed-off-by: Zixin Wang <ywp1023456@foxmail.com>
> ---

Ah, you're too fast! Please wait at least 24 hours before submitting
a new version.

Also, could you add a Datasheet: tag with the CM32183 datasheet for
documentation into the tag block?

Thanks.

-- 
Kind regards,
Joshua Crofts

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

* Re: [PATCH v2] iio: light: cm32181: add support for the CM32183
  2026-10-11 17:31 ` Joshua Crofts
@ 2026-10-11 18:23   ` Zixin Wang
  0 siblings, 0 replies; 4+ messages in thread
From: Zixin Wang @ 2026-10-11 18:23 UTC (permalink / raw)
  To: joshua.crofts1; +Cc: ktsai, jic23, linux-iio, dlechner, nuno.sa, andy

On Sun, 11 Oct 2026 19:31:16 +0200, Joshua Crofts wrote:
> Also, could you add a Datasheet: tag with the CM32183 datasheet for
> documentation into the tag block?

Thanks for the review. I can add the tag, but I haven't been able to
find a publicly accessible copy of the CM32183 datasheet. Here's what
I checked:

- The CM32183 product page is publicly accessible [1], but downloading
  the datasheet requires a My Capella account, and that host's
  certificate has expired, so the page is http only.
- "http://www.capellamicro.com.tw/download/CM32183.pdf" returns 404.
  "CM32181.pdf" is available at the same path, so the URL pattern
  seems plausible.
- The public CM32181 datasheet (Rev. 1.2, 14 August 2013) does not
  reference the CM32183, so it doesn't document the part this patch
  adds.

Since access to the datasheet requires registration, I'm unsure whether
linking to it would be useful to readers. Unless I've missed a public
copy, would you prefer that I use the vendor's product page as the
"Datasheet:" URL, or omit the tag and add a "Link:" to this discussion
instead?

Apologies for sending v2 too soon. I'll wait at least 24 hours before
sending v3.

[1] http://www.capellamicro.com.tw/EN/product_c.php?id=96&mode=14


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

* Re: [PATCH v2] iio: light: cm32181: add support for the CM32183
  2026-10-11 17:02 [PATCH v2] iio: light: cm32181: add support for the CM32183 Zixin Wang
  2026-10-11 17:31 ` Joshua Crofts
@ 2026-10-12 21:21 ` Andy Shevchenko
  1 sibling, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2026-10-12 21:21 UTC (permalink / raw)
  To: Zixin Wang
  Cc: Kevin Tsai, Jonathan Cameron, linux-iio, David Lechner,
	Nuno Sá, Andy Shevchenko, Joshua Crofts

On Sun, Oct 11, 2026 at 05:03:00PM +0000, Zixin Wang wrote:
> Add the device ID for the CM32183. The device has the same register
> layout as the CM32181.

...

> -/* 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
> + */

Make it more readable

/*
 * CPM0 Index
 * 0: device-id (3218, 32181, or 32183),
 * 1: Unknown,
 * 2: init_regs_bitmap
 */


-- 
With Best Regards,
Andy Shevchenko



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

end of thread, other threads:[~2026-10-12 21:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-11 17:02 [PATCH v2] iio: light: cm32181: add support for the CM32183 Zixin Wang
2026-10-11 17:31 ` Joshua Crofts
2026-10-11 18:23   ` Zixin Wang
2026-10-12 21:21 ` Andy Shevchenko

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