From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.167.54 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796024142; b=zkxAVtSbq7SGMRmRzKi89Ynklu/MX38GdpW+lSX1Zj4CVi9C8C/HGl38m24EZPliGPTE SoW+fAwkw4Qc44IX9iw2J05AW6kvZdrSyiCA58xhcPpnUASJWT7Gt7b9rIkl1tFMpxF2Q q9AfaMZj4Goh0Now2EVzS0tlNe4gjGiUKpO4ia2deAUw86DI70RAoZ8U8RZlCNecBQIkJ shm8c+Mp76HRxV7Seb7O4Os+B2T/Hkmmph/BcPScKnHfCHWJTU3K8WokCDgQ7ePFXSewd AU4F2Kh/AbDWVjjGyqZo/yGJMY+efwuZ1zbMJFopuVg2fdYNEYf3ps/1HfFuy+/oz7w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796024142; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Message-ID:Date:MIME-Version:User-Agent:Subject:To:Cc:References: Content-Language:From:In-Reply-To:Content-Type: Content-Transfer-Encoding; bh=wli60krWi0d1Amwv2xmsHUpoVe5bxXwWV9Hx71zR/RM=; b=MkrTH5tQtpQe8Ng/0uToG7Q8NS7kNw5Q3O06f+yVruTEm8fxHw+fwleHIxg1DsqW6fnP sepmpFCwmxH5YjChPeP2ESV1qPLqcSIrYSecuhxwEIbhKg+5H5ApwS7pCJ2DjU808fltH UEtI2Zk6qGByckDL32+2rc+QIYBi/88Dtn0MYCJiglHW/fO6SzLryYR9uMhJKvQnxONzt bALJu8qTxo74BJatpBU3cgygNIKCPH1zsVghNBEkTmeG+J+3KCgVHEtZVko8UMMt+Xu/v NfCxUEsoEy5wAnwtqliomvnhyVG51+cpTs20cj11CKBVVGXtEwsTUFYJZiEact1P92w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=R21awKgO; arc=none smtp.remote-ip=209.85.167.54 Received: from mail-lf1-f54.google.com (mail-lf1-f54.google.com [209.85.167.54]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5DF2C606A325 for ; Mon, 30 Nov 2026 07:35:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 5DF2C606A325 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=R21awKgO Received: by mail-lf1-f54.google.com with SMTP id 2adb3069b0e04-5c31369ae36so3769231e87.0 for ; Sun, 29 Nov 2026 23:35:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796024139; x=1796628939; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=wli60krWi0d1Amwv2xmsHUpoVe5bxXwWV9Hx71zR/RM=; b=R21awKgOUeC9ZNPSed+OZctrb4uI+oLVUv6gyGHW4LeHX12s/UNSBryePyXCSUo8Eq kshMf8h540i7pOi0KJeejSwH5/N8dlANAA8ak1Y4I7oPIXuZ2DL0MVrRU8DW94HpvpyT t3AJX+Tg/lGZQRrbYNuf0ezcr/ugcqiR9rTNuxrFuZdeCqDqhwEUUAuLVbEdBP9dbKuw KWzCG/EZdUT+ZgLUQsCe/mjHTMD2KUix+RShV7aPOXP39UVQVYJnSw2/mhr6xmKZ6ryx o8/8FAbCf4XaHSvBsW/k2ZF/mIaMyuMQ6hz6ZswkWc4jMF/G0waEkTi8uZ6eEeaXrAuH jDYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796024139; x=1796628939; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=wli60krWi0d1Amwv2xmsHUpoVe5bxXwWV9Hx71zR/RM=; b=RQDyYxFRDIkWzc+hqPdfmdyJnsVN9y0r5LTDxLWPhvaoZk0YtYAnK5ir2uO7wOXPjx UVytnKEUoN3WRkpL0ANUxD68rOipBYbogXyysYX5w7xvv8qLGSB4ZvC2G7p/Z7bYycB4 D8+WvYuoyVj4qSqcz9+d158AbM3pgPvIzkwf/06VZA/SLM3J1CXMHC96w5czJvetKRt7 swM3GMERYeAJ8d8W5MBHn3lqqfIuKSii2h3FDyH3v8AUqkiP5ShJjKzI1hZwE42XFcHq kJduR88F84gSLbXOlkvxZBqV98Tq2j5bu8PKp1FLAnf+hYxZ+Vxckr/31rClJ/sp1flG pmsg== X-Forwarded-Encrypted: i=1; AL+hErHQeQAbPdcJ5pMXLesXyQMzQAE1uIfr1Ub/U1QXDdPswPjb1ec+Ipu/AXw89XXsfUdzyCXGviLlx8jUprI=@vger.kernel.org X-Gm-Message-State: APuU4Z+49xPHmT4bL5+TEwIOlJl7j895ocPncZPYRiNyeTCjGmv0ojEF cQ7lRgEy+zK+JYf2nhI4D1Wyw5DyZumpgTDhxAh44dl8TGG424VMp5Sn X-Gm-Gg: AZFdTZfL0hKz+z4pUKNhY0iz18/xsSs+M/YQGspe8uUQ+j2x14lD12zNvj6kcXOO8i9 Mov2TNixqzNu+AipeIhovuGQ1YL6bNdsU1g6h/XtiXlhfGPOzkBR/MgLs1x80OUw8m4wbX/DHLZ 6caMEgFjFHF2EK4COfK+qdI+iDBGuHQVvfBMdYNP6/UgOqlOpUrD3U6Ju77nLcl0/ukr4H4hIbG iLRIk3z88HjXjCvWTL020vlhoxw9oY1tpcWDSooT52ueQSyvJOPP5aNX9ryr1wQC6Dyo30XH7yj RPl1HnkZTH/pMh/h7gEeofx2qJAtHizJyk7aLz8xTKldllzr4uoPvNIxhreqr6DAdAxm8ASvH3F Wfu/vzBTfRNz7fmaMWZdxx0WeT1FjKrxSJYFtBYVyHxY84MFLi+rOFCfErMjMf/bjlD1EXYMzWV 0IvDmBEI44ozOYZEL7kpD9sCK5UgJi2BSX+cuMbwIaDIadRf/nxtA63ph7Qoxw1TAnOe3aAlSH9 wt8hI7YK+q1dT5B40xgyO2+6SL7YwjLDnVqXO+QY0VFCIMzX+8gpqH6faBw5lmjKbfuYQIZgGjJ XfJmlasMUPeV3qDQBUSaiIYy6MyQDbFgtEAPvEKZfgbQda5vfreF1uh7RqAedLv6N+reILC4Ne0 WvYAehbZQzA== X-Received: by 2002:a05:6512:238f:b0:5bf:b999:91ad with SMTP id 2adb3069b0e04-5c1bc807481mr9562492e87.20.1796024138889; Sun, 29 Nov 2026 23:35:38 -0800 (PST) Received: from ?IPV6:2a10:a5c0:800d:dd00:8fdf:935a:2c85:d703? ([2a10:a5c0:800d:dd00:8fdf:935a:2c85:d703]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5c34b0683aesm1498949e87.75.2026.11.29.23.35.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 29 Nov 2026 23:35:38 -0800 (PST) Message-ID: <3426b316-060d-44c2-8aeb-ee9243a55d28@gmail.com> Date: Mon, 30 Nov 2026 09:35:37 +0200 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 2/2] iio: light: add ams OSRAM TCS3430 XYZ and ambient light sensor driver To: Jonathan Cameron , Robert Ijtsma via B4 Relay Cc: robertijtsma@gmail.com, David Lechner , =?UTF-8?Q?Nuno_S=C3=A1?= , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org References: <20261127-iio-tcs3430-v3-0-e191a40a4ae9@gmail.com> <20261127-iio-tcs3430-v3-2-e191a40a4ae9@gmail.com> <20261128014214.1541d7ee@jic23-hlaptop> Content-Language: en-US, en-AU, en-GB, en-BW From: Matti Vaittinen In-Reply-To: <20261128014214.1541d7ee@jic23-hlaptop> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 28/11/2026 03:42, Jonathan Cameron wrote: > On Fri, 27 Nov 2026 09:12:50 +0100 > Robert Ijtsma via B4 Relay wrote: > >> From: Robert Ijtsma >> >> Add an IIO driver for the ams OSRAM TCS3430 ambient light and CIE 1931 >> XYZ tristimulus color sensor (found at I2C address 0x39 on devices such >> as the Microsoft Surface Pro X). >> >> Unlike the older TAOS RGBC drivers (tcs3414, tcs3472) that use the 0x80 >> COMMAND-bit SMBus protocol and RGBC channels, and unlike the banked >> MAZeT/JENCOLOR as73211 driver, the TCS3430 uses ams's direct-addressed >> 0x80..0xdd register map and exposes Z, Y, IR1, and X tristimulus channels. >> >> The driver exposes: >> - Illuminance (photopic Y channel) with raw counts and lux scale >> - Modified intensity channels for X, Y, Z, and IR1 >> - Selectable scale and integration time via the IIO GTS helper across >> 1x/4x/16x/64x/128x gain and 50.04/100.08/200.16/400.32 ms integration >> time settings >> - Regulator management and system sleep suspend/resume support >> >> Tested on Microsoft Surface Pro X SQ2 (SC8180X). >> >> Signed-off-by: Robert Ijtsma > Looking good. > > Only significant remaining question I had is over scaling of the > channels other than the illuminance one. > > I'm not sure how easy it is to make the gts helper deal with the > different scales (it was written much more recently than when I last > touched a light sensor and I haven't used it myself yet as a result!) > > +CC Matti for input on this. Disclaimer: This is just a very quick reply, and I am not sure I understood the problem correctly. Take my words with a grain of salt :) Anyways, if different channels have different scaling factors, then one probably can add more than one "struct gts" to support this. I think I did this with the bu27008. This IC got cancelled and I removed the driver for it from the kernel tree almos immediately after it got merged (after all the hard work reviewers put to it). :/ Anyways, git history still has it: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/iio/light/rohm-bu27008.c?h=v6.12-rc1#n386 Please, let me know if I misunderstood the question :) (Oh, and I haven't really worked with a light sensor since bu27008 either, so I am not too fresh on them either - but I help where I can.) Yours, -- Matti > Thanks, > > Jonathan > >> diff --git a/drivers/iio/light/tcs3430.c b/drivers/iio/light/tcs3430.c >> new file mode 100644 >> index 0000000000000000000000000000000000000000..06e5ecd91f6502a1d8c99de4707e590dac4f5beb >> --- /dev/null >> +++ b/drivers/iio/light/tcs3430.c >> @@ -0,0 +1,521 @@ >> +// SPDX-License-Identifier: GPL-2.0-only >> +/* >> + * ams OSRAM TCS3430 ambient light and CIE 1931 XYZ sensor driver >> + * >> + * Copyright (C) 2026 Robert Ijtsma >> + * >> + * Datasheet: >> + * https://look.ams-osram.com/m/43d518b4cd81e3f2/original/TCS3430-DS000539.pdf >> + */ >> + >> +#include >> +#include >> +#include >> +#include >> +#include > > I didn't check, but do we need device.h itself or can we use > more specific headers like dev_printk.h? > >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> + >> +#include > >> + >> +/* >> + * Photopic Y channel typical sensitivity from datasheet optical characteristics: >> + * ~0.537 counts/lux at AGAIN = 16x and ATIME = 100 ms (36 cycles), giving: >> + * lux/count = 2980 / (gain * integration_time_ms) >> + * >> + * At minimum gain (1x) and shortest integration time (50.04 ms, 18 cycles): >> + * max_scale = 2980 / 50.04 = 59.552358113 lux/count >> + */ >> +#define TCS3430_MAX_SCALE_INT 59 >> +#define TCS3430_MAX_SCALE_NANO 552358113 > > >> +static int tcs3430_apply_itime(struct tcs3430_data *data, u8 atime) >> +{ >> + int ret; >> + >> + ret = regmap_write(data->regmap, TCS3430_REG_ATIME, atime); >> + if (ret) >> + return ret; >> + >> + data->atime = atime; > > Trivial but slightly preference for a blank line before simple > returns of 0 for success like these. Just makes them stand out a tiny > bit more as being the good path. > >> + return 0; >> +} > >> + >> +#define TCS3430_INTENSITY_CHANNEL(_mod, _addr) { \ >> + .type = IIO_INTENSITY, \ >> + .modified = 1, \ >> + .channel2 = (_mod), \ >> + .address = (_addr), \ >> + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ >> + .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_INT_TIME), \ >> + .info_mask_shared_by_all_available = \ >> + BIT(IIO_CHAN_INFO_INT_TIME), \ >> +} >> + >> +static const struct iio_chan_spec tcs3430_channels[] = { >> + { >> + .type = IIO_LIGHT, >> + .address = TCS3430_REG_CH1DATAL, >> + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | >> + BIT(IIO_CHAN_INFO_SCALE), >> + .info_mask_separate_available = BIT(IIO_CHAN_INFO_SCALE), > > Scale is a bit of a weird concept for the various intensity channels > but I'd still expect that if we change this scale, they would be affected > (if it modifies AGAIN rather than the integration time that you are exposing). > Hence I'm a little surprised to see it only here. > > The actual scaling doesn't matter for intensity channels because they are > normally poorly defined though for CIE XYZ we are in a better state than > normal so if the gain doubles they should double. I'd expect the same > for the IR channel. Or am I missing something? > > Upshot, I think this is either shared_by_all or separate but for > each element with appropriate additional scale factors rolled in > I played with an LLM and it thinks the values are a bit wrong for the > listed 2700K white test relecting perhaps a small channel specific scaling? > > I'm not immediately sure how we do that with the gts code. I think that'd require multiple gts instances with different set of scales. I think it should be doable but can't say how complex it'd look like. > Perhaps just keeping the one simple scaling control is the right option > but I think we do need to expose it for all channels. > > > >> + .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_INT_TIME), >> + .info_mask_shared_by_all_available = >> + BIT(IIO_CHAN_INFO_INT_TIME), >> + }, >> + TCS3430_INTENSITY_CHANNEL(IIO_MOD_Z, TCS3430_REG_CH0DATAL), >> + TCS3430_INTENSITY_CHANNEL(IIO_MOD_Y, TCS3430_REG_CH1DATAL), >> + TCS3430_INTENSITY_CHANNEL(IIO_MOD_LIGHT_IR, TCS3430_REG_CH2DATAL), >> + TCS3430_INTENSITY_CHANNEL(IIO_MOD_X, TCS3430_REG_CH3DATAL), >> +}; > Yours, -- Matti -- Matti Vaittinen Linux kernel developer at ROHM Semiconductor Oulu Finland ~~ When things go utterly wrong vim users can always type :help! ~~