From patchwork Thu Oct 17 21:39:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13840873 Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) (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 42D311D61B9; Thu, 17 Oct 2024 21:39:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729201176; cv=none; b=AoVdASQt238YVfxUz53LZuc3caJ3rDY/L2aXHeqVxgl//WwIVx4T6tGE2Ptbrk1fKQQ2T8FNXP1uBZsen92Zbj7Dk8udJWqEqwB2UzXoLMi6a/JY27uA0zgsDI4lvUCdf/5x1imcTVNfp8rEdGVHdz2YJ9NwOJEteBzZbQHNGQ0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729201176; c=relaxed/simple; bh=aoZ0h82kgzuW5AGTpkTwbcGt/l8KTTy/nYspCqa4KPQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=DOlGi4873dOqDNRdYbDFgg/synJUEL50UHarxDNL98az5jDiBT52bFpw8qmXUuDBWsT7cqbIfXACozRbfweDuwGERa1D3x0M3kQf5j3cBtNbq5pGl/2PfpxjVHG8i3lwfRq2YHX5Ki7t7ZRxhAnr0uQlyiEHcaFxCh/f6t1HadQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Leit3GEd; arc=none smtp.client-ip=209.85.221.42 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.b="Leit3GEd" Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-37d473c4bb6so1214242f8f.3; Thu, 17 Oct 2024 14:39:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729201173; x=1729805973; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=oZZskDHhJgNIrqQxqaEa2q6iwbD+pLv8wuGEp1Sg5Mc=; b=Leit3GEdw0TADFPjEKZ+GDsGC9we+hmsGE0OYdMYWiuhgP2hpgx8rVTfjVbb3BbIrc HxosAbrOMyLK1zwsQIqhQK0frv4ACZGFAe9g9q9/rF7kUbjE0OVGk8Ggcg1Xf5iqDwhg PFozB5vtCAXx0AXpyURcbhtBMI1fUKXhMTMSqhlTr5SGtF166Xr1zcoRrfyS2Olp8Edy 8O8rYWyNqBAkaCyrnBH5Zwrib59OqZ4If1j5oXPFceci+D85AmWF3xSrQtXmNWMXb1D4 LPYCfK0JTGIFpqBXjz+rT8Avr+Oa7/dg4SrViMboLG+brEZhj2MqKisbHTWcsvbkQoVj z8EQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729201173; x=1729805973; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oZZskDHhJgNIrqQxqaEa2q6iwbD+pLv8wuGEp1Sg5Mc=; b=QMM1l3Z5Hr/0MvU+2ApevfqW44YUM3+AdqTFyiz/DFPNC/Q6VuW+r+PCBv9vAD6/ZK 8Kh5oFy1WCbLhR8AkBe4gy2P0fgkWo9fkpOA9U2RcKcsZp8bBCcCZeOSwOBJw1YaJpFC o6ws9XLfzac7T3cO0rQyytMN4kpXkp56v/rdxvhZDQfq8m6VcHVm1PuljtSirTlg/KgC LkkxRR0FTC3HXMtYN93l3ZhsOuoSCUU+Gg8u/b2sqUF+UE/E3k1jq956vZV/NxIbuAmS 1nxfCqo9k2L5NQeQM0K8/dbewj3tQXzslf5mD7/QC+HKRss6eA4E+KxA1e+ED9leILDY 0Z2w== X-Forwarded-Encrypted: i=1; AJvYcCWPyg8waa+lDwg5DQWgcM7US5e4FTL7GP4UFMSiQQYz8UEZZkiSEzs7cHpLLwHwMMPx13wRgQQqWriwIr1q@vger.kernel.org, AJvYcCX20AhTJkxsmvton+6+ZxyLJyhc+NrBGbvY1w9/4pubdHPcrhAF8rkYJbLcSogEDNYK4jrhh/aEBXNS@vger.kernel.org X-Gm-Message-State: AOJu0Yx+nCcfd4uvruZd70u6VAIwjgaVdWDn2Ys/E+b2OXx8t57Wkx3k 28SZ4lBulksD7yH0geCchpDexXfde5hi1c3nYAcfM8ggondCgHRZ X-Google-Smtp-Source: AGHT+IGI5hyT7n8T8UqCYtU3lhPOW16lC4VlEzZTrFqou7Nvu5iRvx5YhrdVGqjL/FqSwGW38PCIaQ== X-Received: by 2002:adf:eac8:0:b0:37d:397a:5a05 with SMTP id ffacd0b85a97d-37eb485ed73mr282867f8f.54.1729201173416; Thu, 17 Oct 2024 14:39:33 -0700 (PDT) Received: from [127.0.1.1] (2a02-8389-41cf-e200-bb11-f817-987f-ea1f.cable.dynamic.v6.surfer.at. [2a02:8389:41cf:e200:bb11:f817:987f:ea1f]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37ecf06a73esm99874f8f.43.2024.10.17.14.39.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2024 14:39:32 -0700 (PDT) From: Javier Carrasco Date: Thu, 17 Oct 2024 23:39:25 +0200 Subject: [PATCH 1/4] iio: light: veml6070: use unsigned int instead of unsigned Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241017-veml6070-integration-time-v1-1-3507d17d562a@gmail.com> References: <20241017-veml6070-integration-time-v1-0-3507d17d562a@gmail.com> In-Reply-To: <20241017-veml6070-integration-time-v1-0-3507d17d562a@gmail.com> To: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Javier Carrasco X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1729201167; l=991; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=aoZ0h82kgzuW5AGTpkTwbcGt/l8KTTy/nYspCqa4KPQ=; b=mRM0/5BGvT7x5UCtVg4OVV7VxtwC90/Ax1LgDZxkzuLGj4YkZI5/SiLKEEG3jr07d0JrvjHyN ts2QMOGZsZpCw2g2ivVe+uwpzSFqFxVXSLVZ7oMNXmvsDUl9RJfPJC0 X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= Trivial modification to use the recommended keyword 'int' after 'unsigned' for unsigned integers. Signed-off-by: Javier Carrasco --- drivers/iio/light/veml6070.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iio/light/veml6070.c b/drivers/iio/light/veml6070.c index 898e285322d4..484b767df481 100644 --- a/drivers/iio/light/veml6070.c +++ b/drivers/iio/light/veml6070.c @@ -87,14 +87,14 @@ static const struct iio_chan_spec veml6070_channels[] = { } }; -static int veml6070_to_uv_index(unsigned val) +static int veml6070_to_uv_index(unsigned int val) { /* * conversion of raw UV intensity values to UV index depends on * integration time (IT) and value of the resistor connected to * the RSET pin (default: 270 KOhm) */ - unsigned uvi[11] = { + unsigned int uvi[11] = { 187, 373, 560, /* low */ 746, 933, 1120, /* moderate */ 1308, 1494, /* high */ From patchwork Thu Oct 17 21:39:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13840874 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (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 776521D63E4; Thu, 17 Oct 2024 21:39:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729201178; cv=none; b=Je5geK4/fwVZ7oEk69tX2qU4uMPBQ23RMeweVymBbhcQwlDI9moGgJw8qqDEEIGlqS+UeGKcyH3ooHmwg01ZtmDZYV0+guhu7HkpfmPfIlzVe4S5SLlPzDcwxwoPf+OYOsTurmiRaguE8dsZOTZdMh/Ro/lxk3pQpPh3WgkjIAA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729201178; c=relaxed/simple; bh=slxiBNrlqeaocsJuYNANEU/ajIu9eRQoFxiHcqiRBk0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=leG4IBdP7ato94qWVU1lTysdUi6RL+6ezAKqN3MuYifaTpZefK2kuX2LyZy708NBHNyhPSJd+6Cs/QR/9+nolDyApKmcF19YHDrroheSf/66A6CJNwad+EEzvMwCE4i22o9ii9cc+K5ANsfbWo8t8h7ANhrdhYYgdZGCxX6UqGM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=NK78/tqp; arc=none smtp.client-ip=209.85.128.42 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.b="NK78/tqp" Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-43152b79d25so13784555e9.1; Thu, 17 Oct 2024 14:39:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729201175; x=1729805975; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=rdJ2cXyn1+L+rmE1Dj6EOWFK8um8PXX9Nodw40uyy/U=; b=NK78/tqpOf6g625QMjBSLOka2fwKEW89+zbSgqLn9bTCYYlXjttXmNQIc25++cAEKf pSPD/tIdTDg5uRSDFozaCwz0NH7OqQWpVs/1S5ZYkA4DeN4JpZMDPVPwTeLee3yCvfpZ 0GgfcgpxOuaPJpOTkF4BWbW6jB14RxUsgNBNKCf/w02xpiRwELFeeVlK5E17CXNA1d3o nGPdeHPKo7m+zrf2K3gbsIFSY8MBZYKR3LsakdUBA/jhsfAz9JYrFiraCRevbC6H5Gm6 9f/zBhLjlNCMDkwUyCleaTglofj0aCM9z5Bk+PTqCZn9aEJXf5bQQgWNyRAV3qQNwcVl mH5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729201175; x=1729805975; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rdJ2cXyn1+L+rmE1Dj6EOWFK8um8PXX9Nodw40uyy/U=; b=uFc7UggAvCDLvwEojxFULMphFMAWUdLIhaaP4zkoog4yAMvx/SkrqW8Ow7Z2lrfU9a ujFqyOVX9mE4Qk/jN8Bwja+MElpgHOQfamxV3+BePmAomP5B50ogHkuAhseakuTQYWmK TgLRX21RnN5lVe+J+r10sBqde11/RlG+01VMH0H8VlWGbrrP+C0DmgOIOBrvUvH/Ls3x QYIOR6jCQZYUA6wZ3Jb9zvBq83QiKo8XzD37FKSabBQBWx3YrFbaeqewmZ8iSvj8cSr2 KUl8sNz/aR1jd8Lv1+pS7v/AZObuR2gCWA5eFWU+90Rp2DK5oLzof/ChXMWl1i+zWMgG HMeQ== X-Forwarded-Encrypted: i=1; AJvYcCUWsf1kLYoX+7LHiw0q9YOO4hImMs39lzUaEzxsmk3wMg0VrTXNv6nDkb5PPmZhXxlvLUSJ4Mzdh3sr0L8V@vger.kernel.org, AJvYcCWrLPIyJZQ1ulQFVMULS2d7WlOfno6s/y8ZU6QFrz9rixlCW8HzwF/BS+AgNA7uoZa1UodSGVihlYWc@vger.kernel.org X-Gm-Message-State: AOJu0Yzwfx8QyqVkwkszd4bNvj94c4MbxKjlvq5drVyNzPLifCAd0y1j gZ7c0O0EdruEnACg8V4rFznPROuOwW+k+LguFznX11hn7+dbJnH050EGDg== X-Google-Smtp-Source: AGHT+IGYummoGPooYnT/q6pUWUuP5BSc5r1vEpoZ5LgR9nGJ35uQ5bISaN5qgNQ1GTBnrKb+KAQjWQ== X-Received: by 2002:adf:f992:0:b0:374:c911:7756 with SMTP id ffacd0b85a97d-37eab6e46c4mr211895f8f.38.1729201174633; Thu, 17 Oct 2024 14:39:34 -0700 (PDT) Received: from [127.0.1.1] (2a02-8389-41cf-e200-bb11-f817-987f-ea1f.cable.dynamic.v6.surfer.at. [2a02:8389:41cf:e200:bb11:f817:987f:ea1f]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37ecf06a73esm99874f8f.43.2024.10.17.14.39.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2024 14:39:34 -0700 (PDT) From: Javier Carrasco Date: Thu, 17 Oct 2024 23:39:26 +0200 Subject: [PATCH 2/4] iio: light: veml6070: use field to set integration time Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241017-veml6070-integration-time-v1-2-3507d17d562a@gmail.com> References: <20241017-veml6070-integration-time-v1-0-3507d17d562a@gmail.com> In-Reply-To: <20241017-veml6070-integration-time-v1-0-3507d17d562a@gmail.com> To: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Javier Carrasco X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1729201167; l=1537; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=slxiBNrlqeaocsJuYNANEU/ajIu9eRQoFxiHcqiRBk0=; b=HirTxUkuf9nvMr+RzRmporfD1Xkdr3AZrHGNTqMsRqxouL3XoBX2eOGVRh4+YNHWCuiI+0gV6 k4g6uxS3Ao3AXKoq6pQ3p2dcZTFyoNz9aTRDKJQaFQ+h2bS+QGFY62n X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= Define the integration time within the configuration register as a field to easy its handling as an index, preparing the driver to support configurable integration times. Signed-off-by: Javier Carrasco --- drivers/iio/light/veml6070.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/iio/light/veml6070.c b/drivers/iio/light/veml6070.c index 484b767df481..d11ae00f61f8 100644 --- a/drivers/iio/light/veml6070.c +++ b/drivers/iio/light/veml6070.c @@ -9,6 +9,7 @@ * TODO: integration time, ACK signal */ +#include #include #include #include @@ -28,7 +29,7 @@ #define VEML6070_COMMAND_RSRVD BIT(1) /* reserved, set to 1 */ #define VEML6070_COMMAND_SD BIT(0) /* shutdown mode when set */ -#define VEML6070_IT_10 0x04 /* integration time 1x */ +#define VEML6070_IT_10 0x01 /* integration time 1x */ struct veml6070_data { struct i2c_client *client1; @@ -172,8 +173,8 @@ static int veml6070_probe(struct i2c_client *client) return dev_err_probe(&client->dev, PTR_ERR(data->client2), "i2c device for second chip address failed\n"); - data->config = VEML6070_IT_10 | VEML6070_COMMAND_RSRVD | - VEML6070_COMMAND_SD; + data->config = FIELD_PREP(VEML6070_COMMAND_IT, VEML6070_IT_10) | + VEML6070_COMMAND_RSRVD | VEML6070_COMMAND_SD; ret = i2c_smbus_write_byte(data->client1, data->config); if (ret < 0) return ret; From patchwork Thu Oct 17 21:39:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13840875 Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (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 980E41D79A6; Thu, 17 Oct 2024 21:39:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729201180; cv=none; b=aLkAcn8juGxvuNBzTK1VWjxzR1GwRQzDJimthLW6a/V7lZj6FNuDQbEaUXqaear6KVAQsfysN+vAN14O3q9ZTdDHmQGN4p26Y/XLCfOFqLpGElNJ2GdwirAh3D7owzyZH7ZDA7Seb4lTNQpHRZKzQ+LYxVsO8X3cmSTJq1v3beo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729201180; c=relaxed/simple; bh=XfmpPXJ7lrciSE6RtVOlet67kVCWxt6ObkwJSrdhHrQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=b0EDS4NEYxswhHs3mNsm/60hsCqxNa1hq41zQAQKdtmOyr8C8/Lfvz14MCUNt5Jmabol+ybM5hTmma/muj3+EgMdBBDqZ+ou62n1tMg8AidmE6gDwhVHkiRSvR22+CuIT4BcMyhtabRY11McNgXPpJUSGwdw/oOJvQ8U+kpGras= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=BmuQxz0T; arc=none smtp.client-ip=209.85.128.43 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.b="BmuQxz0T" Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-431481433bdso14441815e9.3; Thu, 17 Oct 2024 14:39:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729201177; x=1729805977; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=R2nkA+EyiMbr9RhGqSZKfXddvPtR+ztqHhHvUR6oxHA=; b=BmuQxz0T8LpPIZlzfDZ4s0WbWzijiZSzas5W6Bv+3Dhc56Hbk2tthIPWg90Q1PgJlg naGT1CyluvFUi3aH3g+yL1lpGy8zuzlH2AJ0VxLVprCuAokn6Bdi7QDYniVY/V3iBnAX 6G9mTL1CEsi0gzsRkVPFHtAWh3qbW5hp5suf4Ck5zhvIkRr9joh2YNbZiAUdT16XABe0 9GkUur56GNs8WmF3LpKPbGrbSCz8AHse3yLUY8JFfteC5J3vPn+eat4B8+otO+rGiyWE 1bWHOCmDI1BdJmIEGbUnwaRKc9BY6zPuWdy9/0ssXM27KHlximGbXIzsFKlN22FAZs2f frLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729201177; x=1729805977; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=R2nkA+EyiMbr9RhGqSZKfXddvPtR+ztqHhHvUR6oxHA=; b=RXpsTGiLWGFfEkDKMtBYX5nEu3k+oEHpDIAYrzZb59DWMdSsF10i/+eSYhBIAk/+kZ xfqBdry/AEjHfOtffKPxoQkNkHXvjt7ML499QQljfEBIEmgJs82hb1gUAfhbmDhIDVr8 Z2afiLU9EF/xSLg7ab23Fh/GEc0kPjj2iKggxep2Fby3Ncg8tAzsV7nsAwNheemj6jBE Ufj/jfOLiSF66hByn5+sRbeqZK/AThKQNRc0fGDJkum667Y8V4C+l8c/e5Ej64YuzIro pYUUOngNIiasUe8bv89Han3RDbmSOoAIyqO0aMt1FG4B6HGgxNzoMRHioXJ6wpiTM9DW LUkg== X-Forwarded-Encrypted: i=1; AJvYcCUVIYgBJfgwjQGcoDrmuAxv5wvINbfVK3DnWqILR9J3B53CUvg25ifJBOgm5EBH6G7mI19oSYo/by5o@vger.kernel.org, AJvYcCWMInAtzYU4YHvuZIcEpJvPEoHFP2600JPm7j1YBlTvLiDAWCh34MSCseW/fdgESd1qG5j5r3V3SySiXWlj@vger.kernel.org X-Gm-Message-State: AOJu0Yy3JYSrWJHHJMk+uigr1wBsAu3Zm4Qrxqzwwqd6pRvuZSxZavdi eEsLLmzYQsAXiceWJhylD/kOAPSPVs7Xcs7qZJI603p/rOLdZXNZ X-Google-Smtp-Source: AGHT+IFF9VmVWlsrG2sVfZuGCchUthzNGpeWMIfhiI1PLc5Fe2e+D5gJBT5+gnlznMkV29rA8hfkJQ== X-Received: by 2002:adf:f605:0:b0:37c:cc96:d1ce with SMTP id ffacd0b85a97d-37eab6ee898mr213628f8f.24.1729201176794; Thu, 17 Oct 2024 14:39:36 -0700 (PDT) Received: from [127.0.1.1] (2a02-8389-41cf-e200-bb11-f817-987f-ea1f.cable.dynamic.v6.surfer.at. [2a02:8389:41cf:e200:bb11:f817:987f:ea1f]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37ecf06a73esm99874f8f.43.2024.10.17.14.39.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2024 14:39:35 -0700 (PDT) From: Javier Carrasco Date: Thu, 17 Oct 2024 23:39:27 +0200 Subject: [PATCH 3/4] dt-bindings: iio: light: veml6075: document rset-kohms Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241017-veml6070-integration-time-v1-3-3507d17d562a@gmail.com> References: <20241017-veml6070-integration-time-v1-0-3507d17d562a@gmail.com> In-Reply-To: <20241017-veml6070-integration-time-v1-0-3507d17d562a@gmail.com> To: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Javier Carrasco X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1729201167; l=1258; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=XfmpPXJ7lrciSE6RtVOlet67kVCWxt6ObkwJSrdhHrQ=; b=GMz/+5QC4THsbJR+HKYXlz3zVSK2wLQzt80VSJqDO0ZdHu0W9YLTb80brsKv0VY33mhiThuo2 jSd9lWJTW82BWwzJ4z5bi/k22Y0doFCT2OvCJC8Tf+nwK90kIJN/FQP X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= The veml6070 provides a configurable integration time by means of an extertnal resistor (Rset in the datasheet) with values between 75 and 1200 kohms. Document rset-kohms to select the integration time. Signed-off-by: Javier Carrasco --- .../devicetree/bindings/iio/light/vishay,veml6075.yaml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Documentation/devicetree/bindings/iio/light/vishay,veml6075.yaml b/Documentation/devicetree/bindings/iio/light/vishay,veml6075.yaml index 96c1317541fa..3d3ffeaa22df 100644 --- a/Documentation/devicetree/bindings/iio/light/vishay,veml6075.yaml +++ b/Documentation/devicetree/bindings/iio/light/vishay,veml6075.yaml @@ -29,6 +29,22 @@ required: - reg - vdd-supply +allOf: + - if: + properties: + compatible: + enum: + - vishay,veml6070 + then: + properties: + rset-kohms: + $ref: /schemas/types.yaml#/definitions/uint32 + description: | + Value in kilo Ohms of the Rset resistor used to select + the integration time. + minimum: 75 + maximum: 1200 + additionalProperties: false examples: From patchwork Thu Oct 17 21:39:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13840876 Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (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 029661D7E3E; Thu, 17 Oct 2024 21:39:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729201181; cv=none; b=eBSImdacXbyJ3AvUMVQfwvKpt57ulTrg50ZH+nOJpYS2RcgbLxYnrUKuIeBTRCBKg6Kx2bzDwte8TJDlA/HZByjGmt98OcT3Cp7YMPkqzRp5x7n7YfzdjQiqWYaDgzURDc0dT5lEZimI4TMaUGB1iuQBODIBtfcCGfEUJxNE7Zw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729201181; c=relaxed/simple; bh=APqvJ6aJQIzO3pKdAUeq4yhas7nl1he/ghZ3uuPSAPU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ljeGOXXxO9xKCFEgCV3SVP3zSgJMZoHLRGFI/xXJO0b8ENgYZWNIh1f7w80FpvafA+jY3AmmioQo9E131vtG2UEh1ZoQf7l2W1tr0UTloMoR+yHMFvVPD1cYT3lSCvuu8T7CzNyYFwAHnKuksJlUumEKkJvr1m8DUZYc6pI75B0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=bDWV0BFt; arc=none smtp.client-ip=209.85.221.48 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.b="bDWV0BFt" Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-37d461162b8so976535f8f.1; Thu, 17 Oct 2024 14:39:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729201178; x=1729805978; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=K01JTLPCFhBJJHzM8KLsJttM33kABYw67HxfGcewzIo=; b=bDWV0BFtJIVnVpxpa+NE/bnZDuJvM4rRbEMxnW/MBA4C0iixVTcYIgec46pxquDzYw o5tOlWuqiFyprqU4uXtJxsN6Z+50xMVzMVk7Ok47Y5TFMI2z+qw8cv9C24gxVAkI2/dA r9D/2vuTLCwvH9pfd0JV+gAduLAX/XwzoQQsr6Q+hKbAsW3zKV7DkqHV8vVmyrCB8ZjU tClZfUcZ36AUQ85fS3TFdOGNbUkfDCSwp/LqKEIXOcJ8gDAvsH9ENhI+Bf5ysd411TeL pSq7xjHyWhcR6WXc8TnfO8cplSbbump39yaIePoKzzxs+3YesYqmYlNUG8mfJTLmP+iU YaLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729201178; x=1729805978; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=K01JTLPCFhBJJHzM8KLsJttM33kABYw67HxfGcewzIo=; b=mrnVKYGlPEP2mnlJepivTURKxZTPPpJSnbqJN5sosQAeGj0GfdpxnYUYUT8/Kt0A2p vAa5/aRrv+EcGD2zyfRJ3k8rRQ/kbPtU5eNfPCsixPkub5n0WhYNcvfb6ugdQpKJjVr1 JsTArgpgbhfbUHPEwDVQjx68QgNnEjchtxVnVkqIXO/JjTyAnEvxaq7QHq90XNmzgIrm R3pF4IkMi0Qy9BwTV2Eirl8fPNJI4QUcOdSho/tmBQZHAjpP3eveBKYGiLaTHvdQgfYM HfuGBzgblsVy6W6kdvCMyDN9uTaA6lIcxrRcA6WbHKAp7hNqLk3r3Lhy+TXtxCs2wtu6 0Y+g== X-Forwarded-Encrypted: i=1; AJvYcCUl1P+WID5MhkIQV7vgWzTjE7jyGIsX/YG6Y+wH21B288Zqd+RTTssVx8CiAPXvaJbgajzsoPEmeHUnBcUB@vger.kernel.org, AJvYcCX74lFU7zpeFhFoHCKDPJbBKn5UQNF+KP5S7/WCSDiEMuuBem3Zfd4QZ0Oienwse1xqjLAuQBD2Y3sU@vger.kernel.org X-Gm-Message-State: AOJu0YyYsMxyXUcFP3P3pviUxQ0NUm9le8BNxx9AZyy1MOPgP45ATlc5 l+THo41v/fdcOIVaTz5RL9fld0HgeEri4+uR2V2IWQJlWp4dtHen X-Google-Smtp-Source: AGHT+IEwb6mIO53fmJ/9AFUuyk3ahB175Co0Q8OQjRLxY92o3W4AnAKiqcUoPN8xR8LoHhRL2Iv87w== X-Received: by 2002:a5d:44c8:0:b0:37d:501f:483f with SMTP id ffacd0b85a97d-37eab6ee112mr175077f8f.44.1729201177990; Thu, 17 Oct 2024 14:39:37 -0700 (PDT) Received: from [127.0.1.1] (2a02-8389-41cf-e200-bb11-f817-987f-ea1f.cable.dynamic.v6.surfer.at. [2a02:8389:41cf:e200:bb11:f817:987f:ea1f]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37ecf06a73esm99874f8f.43.2024.10.17.14.39.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2024 14:39:37 -0700 (PDT) From: Javier Carrasco Date: Thu, 17 Oct 2024 23:39:28 +0200 Subject: [PATCH 4/4] iio: light: veml6070: add support for integration time Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241017-veml6070-integration-time-v1-4-3507d17d562a@gmail.com> References: <20241017-veml6070-integration-time-v1-0-3507d17d562a@gmail.com> In-Reply-To: <20241017-veml6070-integration-time-v1-0-3507d17d562a@gmail.com> To: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Javier Carrasco X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1729201167; l=5086; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=APqvJ6aJQIzO3pKdAUeq4yhas7nl1he/ghZ3uuPSAPU=; b=smgCjhGQ8c3vTx2vwpQegGfVCyR1xleuaew5cwnjxjTQAGchnHsui048dcvb5MH4N+/uabxUk Z4Vy0OwvJOaASmdXyttyHCiU8JOZC5B1PPkl6+CYYfXKVqDxRygriOP X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= The integration time of the veml6070 depends on an external resistor (called Rset in the datasheet) and the value configured in the IT field of the command register. Signed-off-by: Javier Carrasco --- drivers/iio/light/veml6070.c | 109 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 107 insertions(+), 2 deletions(-) diff --git a/drivers/iio/light/veml6070.c b/drivers/iio/light/veml6070.c index d11ae00f61f8..87dc3295a656 100644 --- a/drivers/iio/light/veml6070.c +++ b/drivers/iio/light/veml6070.c @@ -6,7 +6,7 @@ * * IIO driver for VEML6070 (7-bit I2C slave addresses 0x38 and 0x39) * - * TODO: integration time, ACK signal + * TODO: ACK signal */ #include @@ -29,15 +29,78 @@ #define VEML6070_COMMAND_RSRVD BIT(1) /* reserved, set to 1 */ #define VEML6070_COMMAND_SD BIT(0) /* shutdown mode when set */ -#define VEML6070_IT_10 0x01 /* integration time 1x */ +#define VEML6070_IT_05 0x00 +#define VEML6070_IT_10 0x01 +#define VEML6070_IT_20 0x02 +#define VEML6070_IT_40 0x03 + +#define VEML6070_MIN_RSET_KOHM 75 +#define VEML6070_MIN_IT_US 15625 /* Rset = 75 kohm, IT = 1/2 */ struct veml6070_data { struct i2c_client *client1; struct i2c_client *client2; u8 config; struct mutex lock; + u32 it[4][2]; }; +static void veml6070_calc_it(struct device *dev, struct veml6070_data *data) +{ + u32 rset, tmp_it; + int i, ret; + + ret = device_property_read_u32(dev, "rset-kohms", &rset); + if (ret) { + dev_warn(dev, "no Rset specified, using default 300 kohms\n"); + rset = 300; + } + + if (rset < 75) { + dev_warn(dev, "Rset too low, using minimum = 75 kohms\n"); + rset = 75; + } + + if (rset > 1200) { + dev_warn(dev, "Rset too high, using maximum = 1200 kohms\n"); + rset = 1200; + } + + tmp_it = VEML6070_MIN_IT_US * (rset / VEML6070_MIN_RSET_KOHM); + for (i = 0; i < ARRAY_SIZE(data->it); i++) { + data->it[i][0] = (tmp_it << i) / 1000000; + data->it[i][1] = (tmp_it << i) % 1000000; + } +} + +static int veml6070_get_it(struct veml6070_data *data, int *val, int *val2) +{ + int it_idx = FIELD_GET(VEML6070_COMMAND_IT, data->config); + + *val = data->it[it_idx][0]; + *val2 = data->it[it_idx][1]; + + return IIO_VAL_INT_PLUS_MICRO; +} + +static int veml6070_set_it(struct veml6070_data *data, int val, int val2) +{ + int it_idx; + + for (it_idx = 0; it_idx < ARRAY_SIZE(data->it); it_idx++) { + if (data->it[it_idx][0] == val && data->it[it_idx][1] == val2) + break; + } + + if (it_idx >= ARRAY_SIZE(data->it)) + return -EINVAL; + + data->config = (data->config & ~VEML6070_COMMAND_IT) | + FIELD_PREP(VEML6070_COMMAND_IT, it_idx); + + return i2c_smbus_write_byte(data->client1, data->config); +} + static int veml6070_read(struct veml6070_data *data) { int ret; @@ -81,10 +144,14 @@ static const struct iio_chan_spec veml6070_channels[] = { .modified = 1, .channel2 = IIO_MOD_LIGHT_UV, .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), }, { .type = IIO_UVINDEX, .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED), + .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_INT_TIME), + .info_mask_shared_by_all_available = BIT(IIO_CHAN_INFO_INT_TIME), } }; @@ -127,6 +194,40 @@ static int veml6070_read_raw(struct iio_dev *indio_dev, else *val = ret; return IIO_VAL_INT; + case IIO_CHAN_INFO_INT_TIME: + return veml6070_get_it(data, val, val2); + default: + return -EINVAL; + } +} + +static int veml6070_read_avail(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + const int **vals, int *type, int *length, + long mask) +{ + struct veml6070_data *data = iio_priv(indio_dev); + + switch (mask) { + case IIO_CHAN_INFO_INT_TIME: + *vals = (int *)data->it; + *length = 2 * ARRAY_SIZE(data->it); + *type = IIO_VAL_INT_PLUS_MICRO; + return IIO_AVAIL_LIST; + default: + return -EINVAL; + } +} + +static int veml6070_write_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int val, int val2, long mask) +{ + struct veml6070_data *data = iio_priv(indio_dev); + + switch (mask) { + case IIO_CHAN_INFO_INT_TIME: + return veml6070_set_it(data, val, val2); default: return -EINVAL; } @@ -134,6 +235,8 @@ static int veml6070_read_raw(struct iio_dev *indio_dev, static const struct iio_info veml6070_info = { .read_raw = veml6070_read_raw, + .read_avail = veml6070_read_avail, + .write_raw = veml6070_write_raw, }; static void veml6070_i2c_unreg(void *p) @@ -164,6 +267,8 @@ static int veml6070_probe(struct i2c_client *client) indio_dev->name = VEML6070_DRV_NAME; indio_dev->modes = INDIO_DIRECT_MODE; + veml6070_calc_it(&client->dev, data); + ret = devm_regulator_get_enable(&client->dev, "vdd"); if (ret < 0) return ret;