From patchwork Sun Sep 22 22:17:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13809195 Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com [209.85.218.47]) (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 A3EFD745CB; Sun, 22 Sep 2024 22:17:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727043481; cv=none; b=fEbCWJN93PtCpHluCvpv3H6OrJ2kUmiLw8HfIIAerXLT+/5CZ3EWBRIKY5BatYF/K7sCL1fmEQwy1V1RQzO600pDJoAMLnqkeGbCtNAvE8lE16wgK3dbN3mafWbrcfSCrMfqEi8DxKs+GwwutVi1EFAsVxkd48iDBi8jUVCPDNE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727043481; c=relaxed/simple; bh=P5p+Hh0ofpp5AZDc1SNz04zJpI/e4lfi7LuPsD2A6qE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=bLNkVwWa2cEkvOtfbi8VDlQqP/xA7zUdjxqZDjCHsArleUXOVlNMR1VvbC7eXwNwvhs80UXpABdhMp8ct8cfq2LEFXxZKvrT72QCAujngCfVFEe5ama7yfo6IZXGa/JNHaPC5+Y0b3TxTBjQFI3vj9M8XxRy3ie9PEtnJ61lxj4= 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=eAmrJcNQ; arc=none smtp.client-ip=209.85.218.47 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="eAmrJcNQ" Received: by mail-ej1-f47.google.com with SMTP id a640c23a62f3a-a8a7596b7dfso643066266b.0; Sun, 22 Sep 2024 15:17:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727043478; x=1727648278; 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=u5CVvTrJ2msrTdCqfd00y+3rlkucKNIEprj9js6Ycgc=; b=eAmrJcNQLgAE3d+x3zZk8Siu8epv8ZYf4ZRndIWswacga7CPsZaqO8I67kc5r13uTh 6qullRpaq35nerUUAj9rbyppWzL49EwLZFPvyyzVUqusb4sPGnYgPFP2y3v7567RlFlX R37iQfuZcMIVomjzWzBgxCJ1q/Vo7I/Xdvf4Q+v/eijKXUFZmO2Xh2uVQveLmUzmogqb 7AgcQt7pIHTzWGpDZRdd10IUxwicMhpymv6SyxPG1clbHOYtykscswteQzRpoaTh+L7A mruNOqXHqGa8oh1Ni6OSaMaRRYn87RPkV1kF3Tm5w7BCQEC49BdT3Kur0pTI6ZKEgzDg Jp8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727043478; x=1727648278; 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=u5CVvTrJ2msrTdCqfd00y+3rlkucKNIEprj9js6Ycgc=; b=vQ9m9zTWeXEd6rhczc56I4uTQHxhB43jy2qQOjjqXFffkFVmhfaxi9nZ8JAE6Iod5E vUrlU5/wN9ZmyD1sJCTZjWTUmBmpH033BmwbUPQrgL3f0kp/3CcrLqP20YUHs1AcmHS+ TueIu2Wt7nXrDoUNc0FkVrUMLicwykoY7aXbefgTeEQyrMxGikrmpUMUZ34xQlegfhiT 11fvjQeznZoVIq7HpZ16ioLECBSXjutLxSaD6jf5ZadRyfpGOt/a6J7bKiTrBqNmpXJZ +VPx/B0Tkx0ZovrKYVw1qzQMPOEJ5V162yOfO9vtsFTTyv/EJpYVJvawuWS8URaSgGaR DMzA== X-Forwarded-Encrypted: i=1; AJvYcCWH+3neGU2r1Iu+vmzB2BcEBNutauOhQT5dl+dOvEpPB8V3YRObydZdy0jEm9ybZa4QlFvr3ertQeBT@vger.kernel.org, AJvYcCX36LSPgjomVUZ/QO9NwxZcEf684B9QglIPdhoLwk4dMtvgr3Z0t3137EnXF1wuSX4BEqXSlJmAqAzy6hya@vger.kernel.org, AJvYcCXQyh+1LmbRsshoPsAjpAKS4o9ySBXFrXnlKhgurFrHRQ9pn0hrEdB/utq1ceMvgxLF2Z2sm6e0@vger.kernel.org X-Gm-Message-State: AOJu0Yw4pZfbLxsIQf+nk+aV9FGai+qhM3w/13PikQ1+gB+K2Wa+yaC4 hGxY7tYuOBmHZSgTgIO7hWlMIz01P4Pt5nbf+w76sF5P/9atUqtY X-Google-Smtp-Source: AGHT+IH+aJcOSwRSwLKBjNRT5UbMZ7j3xwWo8W/b/ZzJI95Ju3+4wm0A0S/8IaToy++ymoZoYMjXdw== X-Received: by 2002:a17:907:1c2a:b0:a8d:4954:c209 with SMTP id a640c23a62f3a-a90c1d6e85fmr1493271766b.22.1727043477642; Sun, 22 Sep 2024 15:17:57 -0700 (PDT) Received: from [127.0.1.1] (84-115-213-37.cable.dynamic.surfer.at. [84.115.213.37]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a90611164d0sm1126202066b.91.2024.09.22.15.17.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Sep 2024 15:17:57 -0700 (PDT) From: Javier Carrasco Date: Mon, 23 Sep 2024 00:17:49 +0200 Subject: [PATCH v2 01/10] iio: light: veml6030: fix ALS sensor resolution Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240923-veml6035-v2-1-58c72a0df31c@gmail.com> References: <20240923-veml6035-v2-0-58c72a0df31c@gmail.com> In-Reply-To: <20240923-veml6035-v2-0-58c72a0df31c@gmail.com> To: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Rishi Gupta Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Jonathan Cameron , Javier Carrasco , stable@vger.kernel.org X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1727043474; l=1280; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=P5p+Hh0ofpp5AZDc1SNz04zJpI/e4lfi7LuPsD2A6qE=; b=Bg+7vLzgVF/f4i9k91dsQi/UvD/TqLno9y6miJDc8bW232GLgF57qaQ67ZMtKdjTknCSNCEQC /mECX+fBw+OAXD3jSmX/zC2wFNus2W8l5rH+yFeGLuuZRP+cz8iZr0Q X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= The driver still uses the sensor resolution provided in the datasheet until Rev. 1.6, 28-Apr-2022, which was updated with Rev 1.7, 28-Nov-2023. The original ambient light resolution has been updated from 0.0036 lx/ct to 0.0042 lx/ct, which is the value that can be found in the current device datasheet. Update the default resolution for IT = 100 ms and GAIN = 1/8 from the original 4608 mlux/cnt to the current value from the "Resolution and maximum detection range" table (Application Note 84367, page 5), 5376 mlux/cnt. Cc: stable@vger.kernel.org Fixes: 7b779f573c48 ("iio: light: add driver for veml6030 ambient light sensor") Signed-off-by: Javier Carrasco --- drivers/iio/light/veml6030.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/light/veml6030.c b/drivers/iio/light/veml6030.c index 4c436c5e0787..a3dfe56b7eec 100644 --- a/drivers/iio/light/veml6030.c +++ b/drivers/iio/light/veml6030.c @@ -780,7 +780,7 @@ static int veml6030_hw_init(struct iio_dev *indio_dev) /* Cache currently active measurement parameters */ data->cur_gain = 3; - data->cur_resolution = 4608; + data->cur_resolution = 5376; data->cur_integration_time = 3; return ret; From patchwork Sun Sep 22 22:17:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13809196 Received: from mail-ej1-f44.google.com (mail-ej1-f44.google.com [209.85.218.44]) (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 D26957F7C3; Sun, 22 Sep 2024 22:18:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727043482; cv=none; b=eyLx6icBJMTwE9gAiGMMTDk9+ZOP6q0B6Xei5itRTjzOAWUPlDeZRTbgnbvaJUs+U7YfAVjIh52n3+89vWn1FPCJH2gYZyOJyEQJsx0ahQgmtu4uejMkHIeyftbZSovTv4LqMYIMeC3WSAcACuLowtaPKVei8Z44YdsEOa2p3SM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727043482; c=relaxed/simple; bh=EonYSneIWPYxbaJfXi8LlItpdf3jHc1fxjBzf1me3os=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=JMrWtZr4TkHhLcUnGHQOqednoFtYWG/McWy2Fbp3KpOTctSLJ0VR2m2cwWY2edzMdIrQEprn5UFFo0wIdEp+JH/4zybnenwpIrppPisyCpePixbD4dZ5iDPLXI1Q7oadafuprHOtdWKTfp3KiicwnUR9Ewsp8rKLKnMV7pa7xU8= 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=cp0h7b3C; arc=none smtp.client-ip=209.85.218.44 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="cp0h7b3C" Received: by mail-ej1-f44.google.com with SMTP id a640c23a62f3a-a8d0d0aea3cso511977166b.3; Sun, 22 Sep 2024 15:18:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727043479; x=1727648279; 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=0bzmiNVbte7T3ewBmj3Pyyc1MaElC3cTEPj2xZYvjpA=; b=cp0h7b3CJLhawyfUrEpc8MQPr+Wj1kbYN37BCqbChZbNhY5T2Qhkr8MdmsN7HjYznA zbAjzxA5RF8zwlkiXSIfQKpzDmSz2fzP0uiYAOJn3mdsm9ynPi5gTMz/OpYwGXuXuSMn qXrAx3njwTBgm4/GEzBlDIXtPkm1NflFgZPHk9BnvqYCrTC6Fiv/RB38OeRbjGNFJsPj A2yIjY0TG54gn6Crvyj4iYyyOSRXmthLbl8/lrcCaZhHTlnJibClDbfBrrhoVB+Lb2Ki /SW/ZZCWWCeiw8itDspgzYiETPM34lR0VVXn6JTb/HgUB7ZSNOGLCkHDAabNrc5u78aS xqaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727043479; x=1727648279; 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=0bzmiNVbte7T3ewBmj3Pyyc1MaElC3cTEPj2xZYvjpA=; b=lKWNTd/5ygm8jDldhEwnAoAOR04qTYVLI6HLoZOo555HtybA+9hNthmYucQlu5nJmC hPtSK9lYVtGa0uvBrPApPrdYRiBNRMUxlRDlKhht8Td5tykAbiQyFLUmG8sndiMv2cqx joiMel/6kUbQynxB28G9igdT3KFc93V+aFANCwC9FdmVHqKJsEbQOQ/ayz2EIcn+YWgc NuQc0q4hJV2MKQRr2HIfdH89oUh05XhMFsFL0OIavIv+vAlZXWnpBLtJmLXhdU8gAmAT 0wxXFw+LsisiM+P8noZEw79qR0eKE+zExSLTbPXMQ9U5lNzdxygEK2bv+OrQapy7bdtl SmPw== X-Forwarded-Encrypted: i=1; AJvYcCVNDR6xr9kdglBNhmmhk7dHqb0FIQIIQ4ebrjvk1TrLUG7OuppZ3fAJSJ64AKRLGsMKfuvnN6pkt+uX@vger.kernel.org, AJvYcCXwBz2X4R3MX7w4WPgY8iZ3/FjHNmV6uGV5biyPCGpqVMbTfWS72YlENQcSPTMPSprd7B+5ALxA/YGSemLy@vger.kernel.org X-Gm-Message-State: AOJu0YzNoMGUyEzsx0BkZUmd5WBMy7oIxYcqpw48ibVTBvK6qx+3UsvL 6mlrPJgOU9/X14YllmodI0Zo91R+L3VV7W3K04fcs9zHdKEUN/gT X-Google-Smtp-Source: AGHT+IGmYraxuWC6e8umlcTCOfPub93JrctJSQgI6I9Jogb4y5ULTgQ1LgKiIwYAi6LRk+0eB3JNoA== X-Received: by 2002:a17:907:f74d:b0:a8a:8c92:1c76 with SMTP id a640c23a62f3a-a90d5033f31mr890134866b.36.1727043479072; Sun, 22 Sep 2024 15:17:59 -0700 (PDT) Received: from [127.0.1.1] (84-115-213-37.cable.dynamic.surfer.at. [84.115.213.37]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a90611164d0sm1126202066b.91.2024.09.22.15.17.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Sep 2024 15:17:58 -0700 (PDT) From: Javier Carrasco Date: Mon, 23 Sep 2024 00:17:50 +0200 Subject: [PATCH v2 02/10] iio: light: veml6030: add set up delay after any power on sequence Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240923-veml6035-v2-2-58c72a0df31c@gmail.com> References: <20240923-veml6035-v2-0-58c72a0df31c@gmail.com> In-Reply-To: <20240923-veml6035-v2-0-58c72a0df31c@gmail.com> To: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Rishi Gupta Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Jonathan Cameron , Javier Carrasco X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1727043474; l=1580; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=EonYSneIWPYxbaJfXi8LlItpdf3jHc1fxjBzf1me3os=; b=65Njqi7aMcHqjfz4NBpJYZ+rMQ6+6unyAK0suU88bbRVfPdcntv5iJVA30EgbfzXg7aSJ7WYK Iuv0+riFjPCDGHrZ9d9sDzZxqL8NL9bRWo04UGOXFaNaQfMap06JMtB X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= The veml6030 requires a delay of 4 ms after activating the sensor. That is done correctly during the hw initialization, but it's missing after resuming. Move the delay to the power on function to make sure that it is always observerd. When at it, use fsleep() instead of usleep_range() as such a narrow range is not required. Signed-off-by: Javier Carrasco --- drivers/iio/light/veml6030.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/iio/light/veml6030.c b/drivers/iio/light/veml6030.c index a3dfe56b7eec..e412a22474e0 100644 --- a/drivers/iio/light/veml6030.c +++ b/drivers/iio/light/veml6030.c @@ -144,8 +144,17 @@ static const struct attribute_group veml6030_event_attr_group = { static int veml6030_als_pwr_on(struct veml6030_data *data) { - return regmap_clear_bits(data->regmap, VEML6030_REG_ALS_CONF, + int ret; + + ret = regmap_clear_bits(data->regmap, VEML6030_REG_ALS_CONF, VEML6030_ALS_SD); + if (ret) + return ret; + + /* Wait 4 ms to let processor & oscillator start correctly */ + fsleep(4000); + + return 0; } static int veml6030_als_shut_down(struct veml6030_data *data) @@ -767,9 +776,6 @@ static int veml6030_hw_init(struct iio_dev *indio_dev) return ret; } - /* Wait 4 ms to let processor & oscillator start correctly */ - usleep_range(4000, 4002); - /* Clear stale interrupt status bits if any during start */ ret = regmap_read(data->regmap, VEML6030_REG_ALS_INT, &val); if (ret < 0) { From patchwork Sun Sep 22 22:17:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13809197 Received: from mail-ej1-f48.google.com (mail-ej1-f48.google.com [209.85.218.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 460F381AD7; Sun, 22 Sep 2024 22:18:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727043484; cv=none; b=JeSDms4dfwiaeqpXsr9Rfrucmb4ZWBHHIwKJvbp8gDHOBIng1tB+Bpfj+2hdyeaNOzuL9DvXB09z1Jt7atqtxQZ7jygFp1feBISA4ulCFIWcUhhBPDpJXmhjItpX8xC+/df8KlxfUk1lHmiAAnAj7EO8WiE6+1QySNBr37FhUA0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727043484; c=relaxed/simple; bh=2hNnr0G0p4cAYnjHVrBaiV9Cl8oax0EHyQjepu1ne/A=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=MbbeRrw305qMqGisLSdRN4PulXJgcqP1fgbyXJnFKFfOnZfX5fVD2aBhKGw20ufyt35w//okb1rRjl7/7FyOD4Y6ie5SZvM2qOd4ahSAqsgqN3UbUXlMaZbwMZY2zqsteeTFB3Q9eezJ0R7e0gBooVLdxfUN4X3mCMFaWv9k8Ds= 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=Qq+hvH05; arc=none smtp.client-ip=209.85.218.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="Qq+hvH05" Received: by mail-ej1-f48.google.com with SMTP id a640c23a62f3a-a8d3e662791so258403266b.1; Sun, 22 Sep 2024 15:18:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727043480; x=1727648280; 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=hat4AlBF/9tP2fYNihkVV28b7p3hj4YuYqLSFJgd68g=; b=Qq+hvH05Uz+F0CmyTYu8YmrrKkP01npSJsMPUy2zL1mqYIiL3IGONK7Fx2a8MxvhaZ EuV8rsbGlQ3JZ9SVvE+TeeFXN1m99csFw4dD5lhv8gIvWd7P5A5dnIKM08CE55ulmG3M JrpXHNh99O8Tf222YFx5SZDX6SfPdolmjgYwuYmvM7pB8Bcs4Jm7kVt7G3CsQdxKb4VB UbBPj6UEAkKUe1ldGBKe1B3meJQe8/VUUJ1SJhu/FlKXZXE23YbV+DJlu8Lresk0mXxB wYZ8qv9VqzPXcQBCZap4ePLHh74LJhqoclToqXV58Vq+V3t07XX/CPg1hIj0QnrkY2FF xrtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727043480; x=1727648280; 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=hat4AlBF/9tP2fYNihkVV28b7p3hj4YuYqLSFJgd68g=; b=X5DFPlckWB/Go2Vnq4MO+W4dAtKhGSZ6iyJ+5nuK0SFF6GZtq1KqWZNUrBJQsFtZbR bpIR5KNqyCtz6UjjCZFFFjA8Uu+ZaF8LDqj9iF6jJ7UoBpFK6sdndhZ1pXZvQ92q5v9F 316RYs4Jt4bb6/U91Atci0ahJPwg6IW4n4ezppl6p7qX0eEcE8JfxRyU7ZDyIvZZoR/k zoYv288ntwQSTm1rsINWkpzmeT5Usi3u9Zwvgab07CXJDNW3cLSMaR9KqgX7gqHQCAFC 39Mh9xGhyv98W2fBuVu5M/9fyz9spgi2Brk1q4rKDaWB+r4EtCBYpEl4yMIvcpn0PfNF 0+Gw== X-Forwarded-Encrypted: i=1; AJvYcCWtkvnSCbaLPVpeaKMQBCK1m5Fo2DOKwtme//z8mfg3Dia7GkiyKcinMbJxo2J0xBmA/l1A5tOL7mYPz2sQ@vger.kernel.org, AJvYcCWvJq6LUDunOazCvrqxI0W77eKj/x3Gn5NGJww3tLvCgtYOXv+lVcoMBLgBFu7BAM/59Mp28N2Lu4cW@vger.kernel.org X-Gm-Message-State: AOJu0YwgWhKS9guS8+OEPzCV9ZOaBHtrnsQSQbvjgKXNHY8Jgyz7a9s0 jVmcoDE9c2eqxQ0611RPRmVrIMURq/3XBtdwDSujrEJ+KoCAulm0bv8ECFR8 X-Google-Smtp-Source: AGHT+IE6M1lF7nOppXXtQ9GtMnuBqxmCz76k/XzS/imYMv7IJy17mJM5q2ctvZ/n8lnd4b76RMsEcw== X-Received: by 2002:a05:6402:4313:b0:5c4:2fa2:93f0 with SMTP id 4fb4d7f45d1cf-5c46484f335mr13689005a12.1.1727043480514; Sun, 22 Sep 2024 15:18:00 -0700 (PDT) Received: from [127.0.1.1] (84-115-213-37.cable.dynamic.surfer.at. [84.115.213.37]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a90611164d0sm1126202066b.91.2024.09.22.15.17.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Sep 2024 15:18:00 -0700 (PDT) From: Javier Carrasco Date: Mon, 23 Sep 2024 00:17:51 +0200 Subject: [PATCH v2 03/10] iio: light: veml6030: use dev_err_probe() Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240923-veml6035-v2-3-58c72a0df31c@gmail.com> References: <20240923-veml6035-v2-0-58c72a0df31c@gmail.com> In-Reply-To: <20240923-veml6035-v2-0-58c72a0df31c@gmail.com> To: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Rishi Gupta Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Jonathan Cameron , Javier Carrasco X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1727043474; l=4012; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=2hNnr0G0p4cAYnjHVrBaiV9Cl8oax0EHyQjepu1ne/A=; b=FsrlOYqOm5rMA2AoJKiRhET7cKTK88gyXRqkbH3UtOUHLpxYyLyJmaxlt6d0sTLQ4JIhpum68 8nAASmT6fn+A6W7t8Ij+os4me2YT1aiykPAaj32Rr9wDyK0HKyxIa+x X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= Use the more convenient dev_err_probe() to get rid of the dev_err() + return sequence in the probe error paths. Signed-off-by: Javier Carrasco --- drivers/iio/light/veml6030.c | 72 ++++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 42 deletions(-) diff --git a/drivers/iio/light/veml6030.c b/drivers/iio/light/veml6030.c index e412a22474e0..ccabd4c844e4 100644 --- a/drivers/iio/light/veml6030.c +++ b/drivers/iio/light/veml6030.c @@ -740,49 +740,39 @@ static int veml6030_hw_init(struct iio_dev *indio_dev) struct i2c_client *client = data->client; ret = veml6030_als_shut_down(data); - if (ret) { - dev_err(&client->dev, "can't shutdown als %d\n", ret); - return ret; - } + if (ret) + return dev_err_probe(&client->dev, ret, "can't shutdown als\n"); ret = regmap_write(data->regmap, VEML6030_REG_ALS_CONF, 0x1001); - if (ret) { - dev_err(&client->dev, "can't setup als configs %d\n", ret); - return ret; - } + if (ret) + return dev_err_probe(&client->dev, ret, + "can't setup als configs\n"); ret = regmap_update_bits(data->regmap, VEML6030_REG_ALS_PSM, VEML6030_PSM | VEML6030_PSM_EN, 0x03); - if (ret) { - dev_err(&client->dev, "can't setup default PSM %d\n", ret); - return ret; - } + if (ret) + return dev_err_probe(&client->dev, ret, + "can't setup default PSM\n"); ret = regmap_write(data->regmap, VEML6030_REG_ALS_WH, 0xFFFF); - if (ret) { - dev_err(&client->dev, "can't setup high threshold %d\n", ret); - return ret; - } + if (ret) + return dev_err_probe(&client->dev, ret, + "can't setup high threshold\n"); ret = regmap_write(data->regmap, VEML6030_REG_ALS_WL, 0x0000); - if (ret) { - dev_err(&client->dev, "can't setup low threshold %d\n", ret); - return ret; - } + if (ret) + return dev_err_probe(&client->dev, ret, + "can't setup low threshold\n"); ret = veml6030_als_pwr_on(data); - if (ret) { - dev_err(&client->dev, "can't poweron als %d\n", ret); - return ret; - } + if (ret) + return dev_err_probe(&client->dev, ret, "can't poweron als\n"); /* Clear stale interrupt status bits if any during start */ ret = regmap_read(data->regmap, VEML6030_REG_ALS_INT, &val); - if (ret < 0) { - dev_err(&client->dev, - "can't clear als interrupt status %d\n", ret); - return ret; - } + if (ret < 0) + return dev_err_probe(&client->dev, ret, + "can't clear als interrupt status\n"); /* Cache currently active measurement parameters */ data->cur_gain = 3; @@ -799,16 +789,14 @@ static int veml6030_probe(struct i2c_client *client) struct iio_dev *indio_dev; struct regmap *regmap; - if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { - dev_err(&client->dev, "i2c adapter doesn't support plain i2c\n"); - return -EOPNOTSUPP; - } + if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) + return dev_err_probe(&client->dev, -EOPNOTSUPP, + "i2c adapter doesn't support plain i2c\n"); regmap = devm_regmap_init_i2c(client, &veml6030_regmap_config); - if (IS_ERR(regmap)) { - dev_err(&client->dev, "can't setup regmap\n"); - return PTR_ERR(regmap); - } + if (IS_ERR(regmap)) + return dev_err_probe(&client->dev, PTR_ERR(regmap), + "can't setup regmap\n"); indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data)); if (!indio_dev) @@ -829,11 +817,11 @@ static int veml6030_probe(struct i2c_client *client) NULL, veml6030_event_handler, IRQF_TRIGGER_LOW | IRQF_ONESHOT, "veml6030", indio_dev); - if (ret < 0) { - dev_err(&client->dev, - "irq %d request failed\n", client->irq); - return ret; - } + if (ret < 0) + return dev_err_probe(&client->dev, ret, + "irq %d request failed\n", + client->irq); + indio_dev->info = &veml6030_info; } else { indio_dev->info = &veml6030_info_no_irq; From patchwork Sun Sep 22 22:17:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13809198 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 B15BF83A19; Sun, 22 Sep 2024 22:18:03 +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=1727043485; cv=none; b=lMUgm1J5sYFFeBhfx9S4RYTVImHerzl04FqG8z32uUpIOxMqHMIXOCT24ey0cTK8/mQYB7G3loLdrT+VrlW78Vorg3f+QLOcALcGrRSuavey42f/HRNaXasOshOxMNt3QUy33eGWNQ+JTsFJRPydvt8nBHB3EcO6wHVl7PB32Xg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727043485; c=relaxed/simple; bh=J7jjyfVmLZeAMaf/ScISfDN3o/rkisVFLqkrDFejwV4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=VlgMC40LN/NbGm3TsSO2KiLvrti0RP80Og2DHwHhgwVErHVkwgJGeHQ8nkwMdEDcWtRtNz5jGoJKkQpUNEuQyspQPad/ctz7d7t0J7kQb/ML7EQPyOXaEJ1dzZ4mhl9/c1b2LlyhlzMNofZC+2uHRRoy+ucIAWGR2K50wfWHEOs= 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=XZPuZTNi; 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="XZPuZTNi" Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-374ba74e9b6so3015708f8f.0; Sun, 22 Sep 2024 15:18:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727043482; x=1727648282; 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=ldi/jYR5bipK31CSpjyDr0h8RTCEPZFHrXaKF7gFNv0=; b=XZPuZTNi4TVRzuEWht0I5YDbdHOsvf1pEZuVP92cnccShEckqMffpsh2NgnCMMVm+F sF1ePqstwI1XWZPJPB6ECCAFkG2jqwC35AHEW09bo1g++VTQ7HidoYOqxiTBSkJe1txL YfZt6nbIN1Z0QEcPXJi/Z7rHU7EU3VG8etLIDvHlHDc/k9hoHFKfplxGhrSCxshYHj/B Rgs9HxjuI6f4BIlxibEzJHlQ0/ikIaqDFDYv0LckIXltF9X8Sxzf6XxuhX3nE1IUcqoT ApxT5hdN+8/Mdh1W7q8uKG2Wi9+v+tWUHQ6Y1gpy24aiZYCS5vtdqRStFfbn9z+QSUzS +6Gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727043482; x=1727648282; 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=ldi/jYR5bipK31CSpjyDr0h8RTCEPZFHrXaKF7gFNv0=; b=aM4M48I0beWiCgWbpx3mrs532Ldg6c1KZ6wYko2sRrK6Xo26ePuR23jrLSoEFKw/LV Vi17Q9Q1XS+7qAJNf3Cqp4PqL8ZO1sO3Msxm1nIjbISbgzJSNpt7d0qpGohEWsyQUf1U 6CGh4wNzs74zMIOdVhDt3a8mRBQ74RE69/z3jh5tfaoH1E1eMdrBhd06xzUtizjhpH7z fNiiDXSWaub2Ny4iYvaXzEBS9Vxe9OmjXfo728nS4WaDESsrbEHSyEtxLlR+ZluVs42/ TEvUZGXRq2r4O1PtcZs9Kb1bVKAa2xsyL83f/w8cywSKjh/bo9ObrGODWWnz1j36Ze/4 ijHQ== X-Forwarded-Encrypted: i=1; AJvYcCUKomBGUi6+FtQlNaYQxDnbYEByOsNMYRscsaYs574FLJJAvHMiDJnFJkYuMsdFZAFDfTcd6okrP0dg@vger.kernel.org, AJvYcCXz5ESXQiu4FMkq61RDu3cMRL6mnuyRZWAk+4pWxTuLXP9owBO86KBdSVTl961U8CIxZGW08RUcZzJD/pgz@vger.kernel.org X-Gm-Message-State: AOJu0YzPpOAGzBr2gC3rXVTMqEUnBza+Ix8vBRVuyAAOkrYVEU7yIlxe t8b1ePlT5p30qmCUdUoj1qF7HuPfK0ffCONPvJaswVFqyoT7HNBd X-Google-Smtp-Source: AGHT+IE4RHwJYszhiEi2wGUAtZnDU425O2kbfHpmsnoxAdYK2OowmC8eHB3eClOkw2ePStXbYORxdw== X-Received: by 2002:a5d:4144:0:b0:374:c29a:a0d6 with SMTP id ffacd0b85a97d-37a422533bemr7112878f8f.2.1727043481931; Sun, 22 Sep 2024 15:18:01 -0700 (PDT) Received: from [127.0.1.1] (84-115-213-37.cable.dynamic.surfer.at. [84.115.213.37]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a90611164d0sm1126202066b.91.2024.09.22.15.18.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Sep 2024 15:18:01 -0700 (PDT) From: Javier Carrasco Date: Mon, 23 Sep 2024 00:17:52 +0200 Subject: [PATCH v2 04/10] dt-bindings: iio: light: veml6030: add vdd-supply property Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240923-veml6035-v2-4-58c72a0df31c@gmail.com> References: <20240923-veml6035-v2-0-58c72a0df31c@gmail.com> In-Reply-To: <20240923-veml6035-v2-0-58c72a0df31c@gmail.com> To: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Rishi Gupta Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Jonathan Cameron , Javier Carrasco X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1727043474; l=978; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=J7jjyfVmLZeAMaf/ScISfDN3o/rkisVFLqkrDFejwV4=; b=cmWptNJ/AfJvYWFA7PzBbG6UxQF60YDtQzpvKtGBorrTvAWAdZnUuzG7TG2DA1HWjFacp7/6g cTyOoi/Bg3IA0WQrdsi0YJTP5oUoKpb9Qx5nEvHqdCDCGjTBaFLHBFJ X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= Add vdd-supply to account for the sensor's power source. Signed-off-by: Javier Carrasco Acked-by: Krzysztof Kozlowski --- Documentation/devicetree/bindings/iio/light/vishay,veml6030.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Documentation/devicetree/bindings/iio/light/vishay,veml6030.yaml b/Documentation/devicetree/bindings/iio/light/vishay,veml6030.yaml index 7f4995557570..2583b61c8357 100644 --- a/Documentation/devicetree/bindings/iio/light/vishay,veml6030.yaml +++ b/Documentation/devicetree/bindings/iio/light/vishay,veml6030.yaml @@ -41,6 +41,8 @@ properties: interrupt client node bindings. maxItems: 1 + vdd-supply: true + required: - compatible - reg @@ -59,6 +61,7 @@ examples: compatible = "vishay,veml6030"; reg = <0x10>; interrupts = <12 IRQ_TYPE_LEVEL_LOW>; + vdd-supply = <&vdd>; }; }; ... From patchwork Sun Sep 22 22:17:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13809199 Received: from mail-ej1-f43.google.com (mail-ej1-f43.google.com [209.85.218.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 3198D84D12; Sun, 22 Sep 2024 22:18:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727043486; cv=none; b=Xh9LCzNAdt04lhfoh/0niWm8uJqqhC81SUdN0CLyLh+9y35LWEfrh9n41b9Y1Eho1d/72eyEG3r6QJ1QRCxbikVo5tR26L16pQcYqrG6diXcBaf6P4rIhBsjOko5eRUQNNmFUangj+A7htH/kdlvibVU3weaqmXgjnSCFjyFuZU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727043486; c=relaxed/simple; bh=C9SaDL5Gqy8FxtoCb/1ZeQNFzCAM9ANHOsVq7eulza0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=rLY5xtRWh2tABvhQXk/hrwe6O3IKE3zCP9pRrdmP19jFNdKJ119W9K/1wexMnBrJh15XavXI0qeYNu6BeLUs73hTUeTrDYA4AdpGViQgWLUyyyXtl4enIXXytMlVCmHeQ/rILoxDKKHKRVF0fPXrV3EbfruZu0OVcWxFumKWyxY= 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=I0eha6bM; arc=none smtp.client-ip=209.85.218.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="I0eha6bM" Received: by mail-ej1-f43.google.com with SMTP id a640c23a62f3a-a8a7cdfdd80so533611366b.0; Sun, 22 Sep 2024 15:18:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727043483; x=1727648283; 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=K6CY7vwzy9oj4NQxVHEf7BN3LYzmQ5EROEyqCGIj0cU=; b=I0eha6bMcjBn1nh64TNtw+9c+IkIbK7aDQvDcRcAkBn7iX/iuAeaQvM+qbLg7KqpUn B5uoYBWsDnKd5XGYIBUrkCFrdlX9nFKKQxVsOzLwcO21Z1Zl7rF+VHkWPpGIDArhn82R zMkl7AiF6//8qDsYaHb5gOcGzQBSfKtaZmgiECmYuhtX6NP1yHrZuTllzWRLgB22NPSL 6NUKSw/V1ZlxbBD2v9ai+osR7rarWLXFAWMZ/GMYbc47upFRytnkjMWLxLxi4RHPBuQR Z1y0rzPl7FjsURod0zKUy2eOICZdHvzCIdTUZEAF0YUxwQRUREAxSuN4MS+OlxXjwlUG F83w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727043483; x=1727648283; 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=K6CY7vwzy9oj4NQxVHEf7BN3LYzmQ5EROEyqCGIj0cU=; b=o6qSFbivic/+9y6VWq4gYxfXgH/eIulfAGNE41cATYqzUzZ8iEtDCSWuqm5DM1Sd1n 31MLcR/iP7JDdYaLCgt9sisw3sPRZ29Y+iNSox4M4j77GYFM/s9n6m60/zvG5QzcT5dR 4uGRQzDKLSYc29OXEqJIaXqeAzPRjdX6pq+ZzqogGdTOUnhn5BSjmJ8n0sQ3ONQb8k2o k93HBKyT6MJxzAwTbcylS99LaITVJLEMM4Olfwjf4gJJUVMtzeReaPIayvp+LPHNLLLV uMXcPOW915Ss8OT5Ho9YlfMK8r3FDoUXTO/0hU/2NU/Cc3m0OrEq7KA+OaOG8w5JUBgF Ozlg== X-Forwarded-Encrypted: i=1; AJvYcCVJP9lCMjXITqQuEzMfRhMx9xotxe5pYe6iI3H7obVCMYhpESJD/guirummTfVmLyMLAFqKTPkiD1FI@vger.kernel.org, AJvYcCWjHibS+ysyD5HlV1daTqz4sKB8mVRAZu9lRw8R58qXaXpYveBWS4YZ+EEft8d18GvK7AoVzeqeaa51cWRn@vger.kernel.org X-Gm-Message-State: AOJu0YxeI9Ebkgb9uqW4yDUyJZlTul7Hzo4R2cY2BKBRA2i1jdAsd9Rq p+vMaBUq47Mq8zTJ/G0pDS1KLGoZrs2DgdwpoiYByQk3JhHUs/o+ X-Google-Smtp-Source: AGHT+IEqFjddnEcpeG9ysMM/Unt/qUQjLCocbjjPRsQsqCSihMIItEAfmn5W73jznkANokk5WIePGA== X-Received: by 2002:a17:907:3ea2:b0:a90:df6f:f086 with SMTP id a640c23a62f3a-a90df6ff2d3mr914225166b.11.1727043483369; Sun, 22 Sep 2024 15:18:03 -0700 (PDT) Received: from [127.0.1.1] (84-115-213-37.cable.dynamic.surfer.at. [84.115.213.37]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a90611164d0sm1126202066b.91.2024.09.22.15.18.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Sep 2024 15:18:03 -0700 (PDT) From: Javier Carrasco Date: Mon, 23 Sep 2024 00:17:53 +0200 Subject: [PATCH v2 05/10] iio: light: veml6030: add support for a regulator Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240923-veml6035-v2-5-58c72a0df31c@gmail.com> References: <20240923-veml6035-v2-0-58c72a0df31c@gmail.com> In-Reply-To: <20240923-veml6035-v2-0-58c72a0df31c@gmail.com> To: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Rishi Gupta Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Jonathan Cameron , Javier Carrasco X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1727043474; l=1203; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=C9SaDL5Gqy8FxtoCb/1ZeQNFzCAM9ANHOsVq7eulza0=; b=/uzQ4zQ1pyoMJTsenjj/ZKF+rAbSZz712iiWKPprjBjKX4OeoBTpm64gsRnHBrsxpETvRSMeJ i2Bf1DgCse8ALAMJ0epZdF3NNMNnet7cnl3pJrY/bhyPFviiyIYiL5b X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= Use the device managed function from the regulator API to get and enable a regulator powering the device. Use "vdd" as the ID to account for the provided name in the datasheet. Signed-off-by: Javier Carrasco --- drivers/iio/light/veml6030.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/iio/light/veml6030.c b/drivers/iio/light/veml6030.c index ccabd4c844e4..89c98bfc5191 100644 --- a/drivers/iio/light/veml6030.c +++ b/drivers/iio/light/veml6030.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -807,6 +808,11 @@ static int veml6030_probe(struct i2c_client *client) data->client = client; data->regmap = regmap; + ret = devm_regulator_get_enable(&client->dev, "vdd"); + if (ret) + return dev_err_probe(&client->dev, ret, + "failed to enable regulator\n"); + indio_dev->name = "veml6030"; indio_dev->channels = veml6030_channels; indio_dev->num_channels = ARRAY_SIZE(veml6030_channels); From patchwork Sun Sep 22 22:17:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13809200 Received: from mail-ed1-f54.google.com (mail-ed1-f54.google.com [209.85.208.54]) (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 A4028126BE1; Sun, 22 Sep 2024 22:18:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727043488; cv=none; b=SswS0Mrh1SAdQx/Tgn66+dvMaiNqq3lqvyS2MksCnJnuZzrYdQRJpJD0m50uDTWHA4cwzng3TVgC/uRMxeGZLv/164a0JD1l2wpRze7bCL/y10OAU2RTuNCQrNKZ4dS/uLtTRToN61UieXwPdibWxkwdL2Y0xr55mtQcYGVxMIM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727043488; c=relaxed/simple; bh=tDaUVg0BO4msxm0LbS9GostkIi08rcQCmv3UdbaUyQE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=MnuinOP4yabl3VBnfM4S1C7hBywjriLPmOWZebljC/sYy24kFnAfl2bz5l6cCIsM53YpyvyjOyQsM938G1iEwzo8HnF0CUHLXtaxS4nr8OMikLsmd3qNn3vXOEzk4MiCODaxOkmE1aCOKOuLHI7y3u0dt0T/doM/p0BmoYpcgBs= 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=KHtM3Hsg; arc=none smtp.client-ip=209.85.208.54 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="KHtM3Hsg" Received: by mail-ed1-f54.google.com with SMTP id 4fb4d7f45d1cf-5c4146c7b28so4795947a12.2; Sun, 22 Sep 2024 15:18:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727043485; x=1727648285; 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=nInp/K4yJhIwI+rcGwOoZteoQ/fjrAElQVflHLtCmd8=; b=KHtM3HsgxPbUyzlu9OMrP0X+bgOFZyfdVBk0OBJV0+ByjcXiGzCbRCVTEbj9cIVvof Ld8IeT4boQclQMlzIYVcbFZAchm12MR5h/lWF+rCST5c6ebWC+uNRGUyvxBxqohu1hTD BkWBzMx9oaRmrLdgClDxCqwvda9wZnpfn4Yo8k4ppGb3BKhpcLBfm2+UPzwa0Le9jkg/ E3h/X0hUVVkMWPH6zz/ClEG+Jo4rg6lehJx1PtTGRJAMDTDnL2x2wTwdHS7bnt3iIT6g gewU75dp3OvSUSY4tI1xKx8WenHVmuiWQxdZq9GaF2Kj4PVawEqhD90fOTD1oAHYJbt/ C3KA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727043485; x=1727648285; 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=nInp/K4yJhIwI+rcGwOoZteoQ/fjrAElQVflHLtCmd8=; b=rNHD0XhmHJm+gdAUHZqURflxGtzBciANKKXpwGpp6Z001MDRt7+JZ3BX29h+isvgtP D0sSXGRTNqn+2PG8Qe4nrYfHXwmsER+IjuwCskOsVfTiGezIkzHpPoMt9ZoeSiiVIOkS 0br3hsZ84gALCacpRZbMuNTTnHRXt4Dg2yuM1UZos/5DRcxumHQXmlJCOxxL1XE60pds fdy3YPqFVCJuHX46hgpxbZJcOQQPOwshILUPNQ1Fcr9ORDX/CvwGU/ijHYNUr1OOR/Fe lGgUrTlZ92FlqJmRrqdc7A3A9iEQSLl/SvdBi97q2bTL7Qrx9uV/w4+6I5KfH++ZoSPh xwQw== X-Forwarded-Encrypted: i=1; AJvYcCUvkPEMIXXcWdE08J0C/X0Pyou09RsZHEp/UFJ7xelhpB2rY2ht4DKFTDfuD1LSlFTHSxX7oat/GVUmQg5x@vger.kernel.org, AJvYcCXoOGq4Kv83LkbfYTtlps94MyTdjFV7nkSiwHaAT3TbxR6/YJaR44vsc99jbTwHD6GcFUpM5rGuUWCv@vger.kernel.org X-Gm-Message-State: AOJu0YxDmnt/A5iCmcjwYk9He7Sje1WdZ2lFoltUz3onppef0UUQQbYB 1eNfCfix7Elz0v51WxY1vITXfcNdDvquDVgzbH6PLLhaRtYOBtxC X-Google-Smtp-Source: AGHT+IGbqT7vfDpc9Jps9TmGYTUPyMBGbDAZa68ACBrMqx7tSkeQwU4ABzL3/FV8JL+aju7RvLKvAg== X-Received: by 2002:a17:906:d264:b0:a86:c1ff:c973 with SMTP id a640c23a62f3a-a90d5804819mr946297966b.47.1727043484818; Sun, 22 Sep 2024 15:18:04 -0700 (PDT) Received: from [127.0.1.1] (84-115-213-37.cable.dynamic.surfer.at. [84.115.213.37]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a90611164d0sm1126202066b.91.2024.09.22.15.18.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Sep 2024 15:18:04 -0700 (PDT) From: Javier Carrasco Date: Mon, 23 Sep 2024 00:17:54 +0200 Subject: [PATCH v2 06/10] iio: light: veml6030: use read_avail() for available attributes Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240923-veml6035-v2-6-58c72a0df31c@gmail.com> References: <20240923-veml6035-v2-0-58c72a0df31c@gmail.com> In-Reply-To: <20240923-veml6035-v2-0-58c72a0df31c@gmail.com> To: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Rishi Gupta Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Jonathan Cameron , Javier Carrasco X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1727043474; l=4406; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=tDaUVg0BO4msxm0LbS9GostkIi08rcQCmv3UdbaUyQE=; b=7hrucQ3w6dzqJl8YFzbbuZ0xgKwWm591zSTnKF+ORmSxIUP44ngIflpdXBCPsbUntJp9xTqKa /BKvPoqRgKVB6xkWog6OzxvD3D4vAL17vft5yEejQCfoc5xzijTipa3 X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= Drop custom attributes by using the standard read_avail() callback to read scale and integration time. When at it, define these attributes as available by all channels, as they affect the values of both the ALS and the WHITE channel. Signed-off-by: Javier Carrasco --- drivers/iio/light/veml6030.c | 64 +++++++++++++++++++++++++++++++------------- 1 file changed, 45 insertions(+), 19 deletions(-) diff --git a/drivers/iio/light/veml6030.c b/drivers/iio/light/veml6030.c index 89c98bfc5191..a3190fab3add 100644 --- a/drivers/iio/light/veml6030.c +++ b/drivers/iio/light/veml6030.c @@ -58,25 +58,24 @@ struct veml6030_data { int cur_integration_time; }; -/* Integration time available in seconds */ -static IIO_CONST_ATTR(in_illuminance_integration_time_available, - "0.025 0.05 0.1 0.2 0.4 0.8"); +static const int veml6030_it_times[][2] = { + {0, 25000}, + {0, 50000}, + {0, 100000}, + {0, 200000}, + {0, 400000}, + {0, 800000}, +}; /* * Scale is 1/gain. Value 0.125 is ALS gain x (1/8), 0.25 is * ALS gain x (1/4), 1.0 = ALS gain x 1 and 2.0 is ALS gain x 2. */ -static IIO_CONST_ATTR(in_illuminance_scale_available, - "0.125 0.25 1.0 2.0"); - -static struct attribute *veml6030_attributes[] = { - &iio_const_attr_in_illuminance_integration_time_available.dev_attr.attr, - &iio_const_attr_in_illuminance_scale_available.dev_attr.attr, - NULL -}; - -static const struct attribute_group veml6030_attr_group = { - .attrs = veml6030_attributes, +static const int veml6030_scale_vals[][2] = { + {0, 125000}, + {0, 250000}, + {1, 0}, + {2, 0}, }; /* @@ -197,9 +196,11 @@ static const struct iio_chan_spec veml6030_channels[] = { .type = IIO_LIGHT, .channel = CH_ALS, .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | - BIT(IIO_CHAN_INFO_PROCESSED) | - BIT(IIO_CHAN_INFO_INT_TIME) | - BIT(IIO_CHAN_INFO_SCALE), + BIT(IIO_CHAN_INFO_PROCESSED), + .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_INT_TIME) | + BIT(IIO_CHAN_INFO_SCALE), + .info_mask_shared_by_all_available = BIT(IIO_CHAN_INFO_INT_TIME) | + BIT(IIO_CHAN_INFO_SCALE), .event_spec = veml6030_event_spec, .num_event_specs = ARRAY_SIZE(veml6030_event_spec), }, @@ -210,6 +211,10 @@ static const struct iio_chan_spec veml6030_channels[] = { .channel2 = IIO_MOD_LIGHT_BOTH, .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_PROCESSED), + .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_INT_TIME) | + BIT(IIO_CHAN_INFO_SCALE), + .info_mask_shared_by_all_available = BIT(IIO_CHAN_INFO_INT_TIME) | + BIT(IIO_CHAN_INFO_SCALE), }, }; @@ -567,6 +572,27 @@ static int veml6030_read_raw(struct iio_dev *indio_dev, } } +static int veml6030_read_avail(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + const int **vals, int *type, int *length, + long mask) +{ + switch (mask) { + case IIO_CHAN_INFO_INT_TIME: + *vals = (int *)&veml6030_it_times; + *length = 2 * ARRAY_SIZE(veml6030_it_times); + *type = IIO_VAL_INT_PLUS_MICRO; + return IIO_AVAIL_LIST; + case IIO_CHAN_INFO_SCALE: + *vals = (int *)&veml6030_scale_vals; + *length = 2 * ARRAY_SIZE(veml6030_scale_vals); + *type = IIO_VAL_INT_PLUS_MICRO; + return IIO_AVAIL_LIST; + default: + return -EINVAL; + } +} + static int veml6030_write_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int val, int val2, long mask) @@ -684,19 +710,19 @@ static int veml6030_write_interrupt_config(struct iio_dev *indio_dev, static const struct iio_info veml6030_info = { .read_raw = veml6030_read_raw, + .read_avail = veml6030_read_avail, .write_raw = veml6030_write_raw, .read_event_value = veml6030_read_event_val, .write_event_value = veml6030_write_event_val, .read_event_config = veml6030_read_interrupt_config, .write_event_config = veml6030_write_interrupt_config, - .attrs = &veml6030_attr_group, .event_attrs = &veml6030_event_attr_group, }; static const struct iio_info veml6030_info_no_irq = { .read_raw = veml6030_read_raw, + .read_avail = veml6030_read_avail, .write_raw = veml6030_write_raw, - .attrs = &veml6030_attr_group, }; static irqreturn_t veml6030_event_handler(int irq, void *private) From patchwork Sun Sep 22 22:17:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13809201 Received: from mail-ej1-f54.google.com (mail-ej1-f54.google.com [209.85.218.54]) (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 0664D81AD7; Sun, 22 Sep 2024 22:18:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727043489; cv=none; b=fPKuqzpG+nnOw8t3v6kwl2tIvl7Qaw60IAAwMawULiG3owCvx2Q7mnkTJogLw+LdhrXooLJctAONEaaqskXm6Rw1CluLIatbIUnAPAJy0sZRML10pw7s4hr8oBuWp4ffV4TKum8aIYa4OFULYJsgnUELZPCcl7APUh9MY0XvcTA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727043489; c=relaxed/simple; bh=ollvBjvErNXaHNbYeIrSHie4RI9hs0qso3/Fg/qNxRs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=oPq1QKkeMX9ZwBLbAHr5SRiMANNMU1uaRqktRKmj2gxfpP9RB2nvJVrcpvO6czMV8zHsNlIIjBlwK+4yUlIpEki2RqzL9j1Jpl3Kdahwd6AVm+nVXKwFf57u+x1rg7ZwF549DbvAcBJm0jFPACIYAynlBV0IL1bC9cZ+Y+XrjT8= 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=mMmfhrUG; arc=none smtp.client-ip=209.85.218.54 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="mMmfhrUG" Received: by mail-ej1-f54.google.com with SMTP id a640c23a62f3a-a8d24f98215so502479866b.1; Sun, 22 Sep 2024 15:18:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727043486; x=1727648286; 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=atM4/LAX7ZK8RsTsiLHW5ehwcD1lF5iSh5UoPr5wOPU=; b=mMmfhrUGsbvNu4nRiupbk/pTWdW+r+MjhmDwF5RMvd19V97VbmdNwFRtGE1gje3rGc +9+0G1BW9+ptYbuYrM4szDrTUaoYynKdd3JVfYqn+oMhZno2SMlsUEVN+FfYzxMyLIle sGN2NTIDO3HBDceEN3Z2kGIgvW9rT4yQQ0/C/FaDYKxZogHr7mR1PxwE7WV/RyQP97fl /cQnXLc3y/WpYxVF7Yas6p9imkQPgv2wPOcMDcq7oCooTGB7APgidu7Z6NB2Uk7ik2wb yL+BlZKKbFfvyUeDWkv8aODB0LYxPef7z2dNfAUe32kCtU6QHkPp46YPOkraoQGjmrxe /LOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727043486; x=1727648286; 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=atM4/LAX7ZK8RsTsiLHW5ehwcD1lF5iSh5UoPr5wOPU=; b=mx/uBkT1X1jnvrRYAolTBzXir54jyJxPp7Z/M2CCyqlw+An+k4VbyUeo0SSpAWjeJk 3+qysBe4tCMqfxMwR0r6vtjZFZjElWaPpoz4oOagstTznA9j+C2TQ88/6lzAUfv+RjmG 63eBOKIYPKJ5w+peEdeoYIAlOHJZ0yHB9o/o9yeLBWYdIyzurrA88ADJkbEpyNHP6ir7 0tvmY3bEtZ4Dl3V3Z/vW7exm+kRxN9MrIspnJe7qvPO//6aPsmQHtvnYK5dZBHn4vREe 6rJcaephxb2b3w7ADMd9wdiPe9inQyPi/NWPGvsIZKQfM0pJGnQ5TvF+JjgCrc+vOIBh y4iA== X-Forwarded-Encrypted: i=1; AJvYcCVEWzjYpLd/aZjSFH/cKUgxI4y9LQfgzg5iKgB3e02WtZ3uaAP//UrJysrBFXa9H9CKRYhyGK7hUkQ99jDZ@vger.kernel.org, AJvYcCXNhJYaIr95Tv6ONYRMQKyRbkM15QcNOgMuNdNfQZmIyffDgXbIPksSzQ3tr0dy/COmtJAQsGGRu2CZ@vger.kernel.org X-Gm-Message-State: AOJu0Yx3UEcaSOBPsw11lEvBd2b5OGdkuOH7dLeAFJ6F9laJ5U8LAWU4 lY5StueIptu3jTckaPTDnMBb+WHH29e54vgdR60U1wh76Lt510Ia X-Google-Smtp-Source: AGHT+IEh0lYznsv1d+yTj9tXE+5nroz1XY5UUh67nl1K5P7PwmK1LwWrZtJwNUvBNc8SqcnZHbcPbw== X-Received: by 2002:a17:907:1b02:b0:a7a:aa35:408c with SMTP id a640c23a62f3a-a90d4fbc6c2mr1129133366b.8.1727043486208; Sun, 22 Sep 2024 15:18:06 -0700 (PDT) Received: from [127.0.1.1] (84-115-213-37.cable.dynamic.surfer.at. [84.115.213.37]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a90611164d0sm1126202066b.91.2024.09.22.15.18.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Sep 2024 15:18:05 -0700 (PDT) From: Javier Carrasco Date: Mon, 23 Sep 2024 00:17:55 +0200 Subject: [PATCH v2 07/10] iio: light: veml6030: drop processed info for white channel Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240923-veml6035-v2-7-58c72a0df31c@gmail.com> References: <20240923-veml6035-v2-0-58c72a0df31c@gmail.com> In-Reply-To: <20240923-veml6035-v2-0-58c72a0df31c@gmail.com> To: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Rishi Gupta Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Jonathan Cameron , Javier Carrasco X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1727043474; l=1693; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=ollvBjvErNXaHNbYeIrSHie4RI9hs0qso3/Fg/qNxRs=; b=GdOy8wmI4+hpirhee48CrGf1J4w5x6XzqU+uDExl15LIfVu8cSLmAR8imWN0X2QUyICuA8id/ EO89CSpyhbPDERQEjvDZaTOREmHxjEKtKfo/AlO4WSs6wAWOBdrLdAI X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= The resolution of the WHITE channel is not provided by the manufacturer, neither in the datasheet nor in the application note (even their proprietary application only processes the ALS channel, giving raw values for WHITE). The current implementation assumes that both resolutions are identical, which is extremely unlikely, especially for photodiodes with different spectral responses. Drop the processed information as it is meaningless. Signed-off-by: Javier Carrasco --- drivers/iio/light/veml6030.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/iio/light/veml6030.c b/drivers/iio/light/veml6030.c index a3190fab3add..861bdf2edd4d 100644 --- a/drivers/iio/light/veml6030.c +++ b/drivers/iio/light/veml6030.c @@ -209,8 +209,7 @@ static const struct iio_chan_spec veml6030_channels[] = { .channel = CH_WHITE, .modified = 1, .channel2 = IIO_MOD_LIGHT_BOTH, - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | - BIT(IIO_CHAN_INFO_PROCESSED), + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_INT_TIME) | BIT(IIO_CHAN_INFO_SCALE), .info_mask_shared_by_all_available = BIT(IIO_CHAN_INFO_INT_TIME) | @@ -549,11 +548,6 @@ static int veml6030_read_raw(struct iio_dev *indio_dev, dev_err(dev, "can't read white data %d\n", ret); return ret; } - if (mask == IIO_CHAN_INFO_PROCESSED) { - *val = (reg * data->cur_resolution) / 10000; - *val2 = (reg * data->cur_resolution) % 10000; - return IIO_VAL_INT_PLUS_MICRO; - } *val = reg; return IIO_VAL_INT; default: From patchwork Sun Sep 22 22:17:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13809202 Received: from mail-ej1-f46.google.com (mail-ej1-f46.google.com [209.85.218.46]) (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 3B4C684D12; Sun, 22 Sep 2024 22:18:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727043491; cv=none; b=L1uprLUzDFEThgyWZagNURDPcgGm4CI8yn+GBJW5Kj1y/NDivVcOapfcKKDg0sApvGdPlnrPrHfourf68DejrB+WYa/OBjdj3GygZfQ8kRXuXcorn/p4U1RNa77OZYQol5yD/dhBWlcMmO46XOoI3gLMb1xcM+GxtHQvhjzMOp0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727043491; c=relaxed/simple; bh=LwEcg3PCOM1SofU6cDRNJICLyss4V52FTFGAQA+uy5U=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=azkxkhV0j0tUcYZub61zUo/ayHGPcOs7Inbx4KsjQGJ3DQuyOw2bh6Lt/qFUQI2f/iN5xS2JQFLguTCE0hm6Bxwl94evK46tcb6x4rVOQ6RfPrQuo4cuUMmpLa/vKyUdosjevIk21l7E5HY2ZXV3XGkiSgkjRwJcngbffSzgh0U= 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=YZRh/PaZ; arc=none smtp.client-ip=209.85.218.46 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="YZRh/PaZ" Received: by mail-ej1-f46.google.com with SMTP id a640c23a62f3a-a8d100e9ce0so452990466b.2; Sun, 22 Sep 2024 15:18:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727043488; x=1727648288; 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=aVD9M4uTcrIfpcx+PQ6CN0y0T3E8wYUNamVjDuflMws=; b=YZRh/PaZEq2AeVVPEEVqfnmLRzvJNd9z8rZ/WvgNej4AJekj7FPsiQFbV/5FhLz4dB SWO3GPn9givj1jBYTWxjuB9g33fTQVk3L5Gt06dtDcjXEOSMBWwRey973sgONizzd/NS Gt3n1/sJor/AUKnBn9iSw22J07ujZKqI7Deo1ktnH4pQHdlBxdmki7LHZKOuYNlgFuWH 9Af1+7OMvRFy/r6UPxmtEyiM5X/SBGTHQZUqOJA5TCtI4noXU/JrFJqfKkF4FBZWKJob rFfIITdOLdUk/YuUTi3gDN5NmxYd2FkJzv2w9glxvqgnMDdZBmQW89MEB7Gv7SR6J8oE T5vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727043488; x=1727648288; 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=aVD9M4uTcrIfpcx+PQ6CN0y0T3E8wYUNamVjDuflMws=; b=ID9wobHFyxhbHe+JAf8k8qhaohpqfrx0Z2FxdNszLqLIq50kr7YsVCDBp2Bk3JLPd0 xl0hT325FuSpNhhnj+6vOzs1ig5wI8kefdr1RlwZ46RnDi9t7L7B5UySea/C4HZUOvcs rhDe19+I8mXl8/JNcr0iwOvxfHs1VgYgLIHeG8f6PlPFd3zofuPcFm7OogZPEoRFZ8Wb qlqSJXwBgJwvGgsP5VMVl0U4fW7iKxSQT5fRnozfS9ru644g+JVD6s8nk6Ai4f0D70fb CRr7jYezUMcF9JTPQ42lJi2TifY0kW2IsR5XdkFf13zs4EYFRiOwaMdZDqgRuOiJmwGs cJJA== X-Forwarded-Encrypted: i=1; AJvYcCUsjqR/TWB/la3RX760b1CYQFHNEg2Vrg+zotlNgRv88E0W3BItHM40SyOb5z3OmK3EUYJi7/WTN6CmYMKP@vger.kernel.org, AJvYcCXpof8yBuev6dd1l6THp5PhDtZfetfF9c7KCiTfJrjrA2E2O8hOINYG6aTUsOSz9U+K+BpabgsEEr4n@vger.kernel.org X-Gm-Message-State: AOJu0YyfV04bnwAAFnRgQNC0N4d/7A7gK31tIL+QtNP3g/X07z8AIUdQ d/06HYXZmVboWXgMNm1SK6T4KzE2unbfJ9iiPvgaJTWmjLz3n1My+JOlj2uZ X-Google-Smtp-Source: AGHT+IEa4PkXmrUSBa15Lh6mKNve0p2Fxv6QV71vbi7OfTytfZtZNe7g6y1ul7SFoKSH7X1yZdQeug== X-Received: by 2002:a17:907:9346:b0:a8f:f799:e7d0 with SMTP id a640c23a62f3a-a90d549c3d7mr995470966b.5.1727043487505; Sun, 22 Sep 2024 15:18:07 -0700 (PDT) Received: from [127.0.1.1] (84-115-213-37.cable.dynamic.surfer.at. [84.115.213.37]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a90611164d0sm1126202066b.91.2024.09.22.15.18.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Sep 2024 15:18:07 -0700 (PDT) From: Javier Carrasco Date: Mon, 23 Sep 2024 00:17:56 +0200 Subject: [PATCH v2 08/10] iio: light: veml6030: power off device in probe error paths Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240923-veml6035-v2-8-58c72a0df31c@gmail.com> References: <20240923-veml6035-v2-0-58c72a0df31c@gmail.com> In-Reply-To: <20240923-veml6035-v2-0-58c72a0df31c@gmail.com> To: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Rishi Gupta Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Jonathan Cameron , Javier Carrasco X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1727043474; l=1379; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=LwEcg3PCOM1SofU6cDRNJICLyss4V52FTFGAQA+uy5U=; b=I7lzY9QRMbTyURqLSoXJ31iysm4FK0q6OsQPh7bW4NKGFQTuEkC7MmYXlQO02KYDxtmNSOpJQ vQNvfNPihnyC2kimPijSI55q/vCOa1d7NVZfDcvSIVbM6g0JW667rqa X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= Move devm_add_action_or_reset() with a device shut down action above the hardware initialization function to ensure that any error path after powering on the device leads to a power off. The power off action is carried out by setting the VEML6030_ALS_SD bit of the VEML6030_REG_ALS_CONF, which is harmless in error paths were the device is already off. On the other hand, making use of the registered action in all error paths makes them more homogeneous by avoiding special action depending on the current power state of the device. Signed-off-by: Javier Carrasco --- drivers/iio/light/veml6030.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/iio/light/veml6030.c b/drivers/iio/light/veml6030.c index 861bdf2edd4d..19c69bfad8cb 100644 --- a/drivers/iio/light/veml6030.c +++ b/drivers/iio/light/veml6030.c @@ -853,12 +853,12 @@ static int veml6030_probe(struct i2c_client *client) indio_dev->info = &veml6030_info_no_irq; } - ret = veml6030_hw_init(indio_dev); + ret = devm_add_action_or_reset(&client->dev, + veml6030_als_shut_down_action, data); if (ret < 0) return ret; - ret = devm_add_action_or_reset(&client->dev, - veml6030_als_shut_down_action, data); + ret = veml6030_hw_init(indio_dev); if (ret < 0) return ret; From patchwork Sun Sep 22 22:17:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13809203 Received: from mail-ej1-f41.google.com (mail-ej1-f41.google.com [209.85.218.41]) (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 9146A130ADA; Sun, 22 Sep 2024 22:18:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727043492; cv=none; b=hq3i8itZDjRcmM/cn1Tyjzi/bBOFHehk03FKUp8+pKGjgCWDk+X+dPk93kcnjR62TsWH9kC6vdqUhv2nZTMMIGLz+jb+OWjZPfQORFihd9SoKIXvktn/E+n35X1tw1G0hLB8w5Rxw4kAiIpQivul8Hab1ilFHoH9WgR3R64Uq58= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727043492; c=relaxed/simple; bh=v76tVZJ0W+acWKyOV/Gx+qBJtt0HMqLGPKyH78bj3Vc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=pUeZQM08hou9E2tiQSx6MOc5+z3xgnR4a1grUruCl6pYBPOaXkLMEkrefGI6b8WIf27WGA45AEHn7VVTZV7b49cKf6gK4sZJesgIf4LJHgcdAuCB9inppkErGGpr9HaLXFn/CDBosFRIxNLmLZ2JIg4Ksnq7jU7Z0L2tAYd2vRU= 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=ZnWstA1e; arc=none smtp.client-ip=209.85.218.41 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="ZnWstA1e" Received: by mail-ej1-f41.google.com with SMTP id a640c23a62f3a-a8a7596b7dfso643079766b.0; Sun, 22 Sep 2024 15:18:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727043489; x=1727648289; 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=5o8vKCa+LjmRjp9pULN5CS7y20Oqn8Tin5hh9qJ+rR0=; b=ZnWstA1e6POBlhEvdnb0mPlfa/Dl8pK3BMSgVMW2R9LBChf7xKBfaAuY5mJrvx+2WF f2nKnfKPgX+jqsfGzosdjdz9rCJr819zPOpeqnb08WDz2rgpS7XZOpYrFFDhTyo3pxhn KoIlfbRgWpT0wu59+rqeWlgGD7NDzTTpfpfu1EYoZ61TPrk46nsODbi55EorXXnmEBUv qKL7ltHKEgJ5fU6lwTVms7rH4w5+1AxMq38pxf5uvKYzSF9U85cB0YIAQ9tT4cMKFaEB zlkJuLsygVJG+Jz8uw0KL//e6ByT0SNbJksP+KtXWgYPjUHsWAHpHhlxjLvcGEFXqO0V 2DsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727043489; x=1727648289; 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=5o8vKCa+LjmRjp9pULN5CS7y20Oqn8Tin5hh9qJ+rR0=; b=M5VRwSoWNCfY52nuKI4F5t6VAU92THJGGuhezk11GqMyyREYUaRoCU8VWGyThczYt7 Bb661BU0uzuiv80K6UANVDXwpS396UNlPy+5iAWLfCq1bv4BTpS73reHG5Gp5rqqH1HP 277Bq7LQxUKpn7a0Ddk/Va4NjmmtnUwISj4fUTQymrmKDFCig3yoSJG2nGeVnjuckq4K zt21fA/eALy5kBe4yhi370GROchjUU1XkznGVANlqjC/ip5i7zcZrqHpmI2TDVXzcIW9 G4/B9pzKiffF/qV8m6odBpwtAf1mRHyj/RDllRbFvR4hTKj8DU3ebk+nrhaatkwtcwoU fh5w== X-Forwarded-Encrypted: i=1; AJvYcCU3A3fcLoDbepIKBRAeaREAaWJMfobW4ekYLoX7G+6Nb5kEpZqU3ho2uL6QrHyADynV/1UE8LmAQTCe@vger.kernel.org, AJvYcCVC6YkxvjkzXIpdOoJHe2x/VSSVZYDf6Rh2qM5ojSqfK7MbGdC0IYVtLe8OSfIT8aj47u6LqmT4zHCuGJy/@vger.kernel.org X-Gm-Message-State: AOJu0YxIUVSmM+UplLBlCW79krIbopxCRujtq5YbtZD09Ur67ICcoqtp 1+qyJ8abiCHwbo5IZQINx26rQ4pqJFTAA/TfqM59/YVEmIXIrKelxQ3lBWRa X-Google-Smtp-Source: AGHT+IFcmmhwvTHvAm5wG4BFxmk3nTb64f+pRzNleklgbDCFZcXnrwyH2jsF/QlN4tKzCb7OwhEH6Q== X-Received: by 2002:a17:906:478c:b0:a8d:4cec:fcec with SMTP id a640c23a62f3a-a90c1d6ee1fmr1625858666b.26.1727043488759; Sun, 22 Sep 2024 15:18:08 -0700 (PDT) Received: from [127.0.1.1] (84-115-213-37.cable.dynamic.surfer.at. [84.115.213.37]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a90611164d0sm1126202066b.91.2024.09.22.15.18.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Sep 2024 15:18:08 -0700 (PDT) From: Javier Carrasco Date: Mon, 23 Sep 2024 00:17:57 +0200 Subject: [PATCH v2 09/10] dt-bindings: iio: light: veml6030: add veml6035 Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240923-veml6035-v2-9-58c72a0df31c@gmail.com> References: <20240923-veml6035-v2-0-58c72a0df31c@gmail.com> In-Reply-To: <20240923-veml6035-v2-0-58c72a0df31c@gmail.com> To: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Rishi Gupta Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Jonathan Cameron , Javier Carrasco , Conor Dooley X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1727043474; l=2791; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=v76tVZJ0W+acWKyOV/Gx+qBJtt0HMqLGPKyH78bj3Vc=; b=EptbaO69DKZ720L6uO0N+AQMv9KH+kws7wK/sVF1r1vPgCQwy5J14AMB0Hv3br85drfxXW1+T AMZJOkCb7Z8CyoIeNwqPz5SVpD51i+7f4SfTwJ7t7v6aNK1GTvt3pl0 X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= The veml6035 is a similar ambient light sensor to the veml6030, and from the bindings point of view, it shares the same properties. Its only difference in that respect is a different I2C address. Estend the existing bindings to support the veml6035 ALS. Acked-by: Conor Dooley Signed-off-by: Javier Carrasco --- .../bindings/iio/light/vishay,veml6030.yaml | 40 +++++++++++++++++----- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/Documentation/devicetree/bindings/iio/light/vishay,veml6030.yaml b/Documentation/devicetree/bindings/iio/light/vishay,veml6030.yaml index 2583b61c8357..69ca10cab09a 100644 --- a/Documentation/devicetree/bindings/iio/light/vishay,veml6030.yaml +++ b/Documentation/devicetree/bindings/iio/light/vishay,veml6030.yaml @@ -4,14 +4,14 @@ $id: http://devicetree.org/schemas/iio/light/vishay,veml6030.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# -title: VEML6030 Ambient Light Sensor (ALS) +title: VEML6030 and VEML6035 Ambient Light Sensors (ALS) maintainers: - Rishi Gupta description: | - Bindings for the ambient light sensor veml6030 from Vishay - Semiconductors over an i2c interface. + Bindings for the ambient light sensors veml6030 and veml6035 from + Vishay Semiconductors over an i2c interface. Irrespective of whether interrupt is used or not, application can get the ALS and White channel reading from IIO raw interface. @@ -19,20 +19,18 @@ description: | If the interrupts are used, application will receive an IIO event whenever configured threshold is crossed. - Specifications about the sensor can be found at: + Specifications about the sensors can be found at: https://www.vishay.com/docs/84366/veml6030.pdf + https://www.vishay.com/docs/84889/veml6035.pdf properties: compatible: enum: - vishay,veml6030 + - vishay,veml6035 reg: - description: - I2C address of the device. - enum: - - 0x10 # ADDR pin pulled down - - 0x48 # ADDR pin pulled up + maxItems: 1 interrupts: description: @@ -47,6 +45,30 @@ required: - compatible - reg +allOf: + - if: + properties: + compatible: + enum: + - vishay,veml6030 + then: + properties: + reg: + enum: + - 0x10 # ADDR pin pulled down + - 0x48 # ADDR pin pulled up + + - if: + properties: + compatible: + enum: + - vishay,veml6035 + then: + properties: + reg: + enum: + - 0x29 + additionalProperties: false examples: From patchwork Sun Sep 22 22:17:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13809204 Received: from mail-ej1-f41.google.com (mail-ej1-f41.google.com [209.85.218.41]) (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 D384D7EF09; Sun, 22 Sep 2024 22:18:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727043494; cv=none; b=C0Zs5NN5WpWdIfoITMx4TarVjCrjpUsRrNQ+pf3f7ISZPJHIKdFE+cnWNaQ6dIp1ovbZFUqg5QV3fY0+6yr7ldWlZ8dXDkXDL8ekjA9pprWg5fZiTIi1XtWTagZxitYEwCV3LUKk8w0XnxBWHwCmivSIv2Z/074qDjenbhDpt3Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727043494; c=relaxed/simple; bh=+q0HZm1fKYjGmC3vzyj1zQ35NDKLymKJHg/syO6dFQQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Ws69f2DYzTxWa91u3Bj8Q1qMYdRiZUZKJVTE2fCgxMzl9dUaj9aJhjUQpdebTkc+9MU+4cjjJSYHOi6JzqiiK4PrEc+KxQxT5CjTPddfwrr4LNNLKdGLVa9oHF87j55UdA+kklib0WTIsCQ+nq6ppFJ+2mafYNvr1BGy0wr1apA= 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=d6mc8OnH; arc=none smtp.client-ip=209.85.218.41 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="d6mc8OnH" Received: by mail-ej1-f41.google.com with SMTP id a640c23a62f3a-a8d51a7d6f5so555723666b.2; Sun, 22 Sep 2024 15:18:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727043490; x=1727648290; 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=gGEeYvPXX8SDLK5PLcriklcqRkSODY2YvcKvFKnL6qM=; b=d6mc8OnHa4qpG4mLcADLpeSHBrFmaLcuQs5pSXUwRn3/ELMuwuhIqAcawSFmbsSn6e cOTLL7lcRYEzsQBDoiJ8c1ibFAeXuSvZm/RE4WQR0CL4y8+t/I5ohwXFZ57eNIbPUlo3 lCiv92elWTI+KMtWxhuE4s489xaHYuDC07EFsGO+tpcWuR3bn3P2q6VReiVFNdJd/Xtc T5W+/K5DfVJzgitl42D9VKkmR/QKx7zxo7H+5jJ1LYMyOBSuqZqRuN0HljigSvI8kIzD UivxGKwEp8Le1EsIiYeO2M9tFYRNf4mCS3z/OCO4N/Fp9292ZX8IrNma7en4tNmdnWhO +EUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727043490; x=1727648290; 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=gGEeYvPXX8SDLK5PLcriklcqRkSODY2YvcKvFKnL6qM=; b=P/MpJliGhy0EIqrupL3AXlbOhZOzT7bE/mwHWbN4fTYwd69vHtOd7C1kHVQSSowhF3 0QiHN8n+PLGofNlk9Ma6IQMvseyJfqEHhGNdEf67R+7GsO3ymhCK6icow5HDbIUvhsCp whzHPMK1OPVXkpIZNYOhKtvDoG2umt8mwpdYOC5SSBD1e1FcEE5mYHdN7QKNoL3hlpda Me/vQwLh+56KaEMkPH8qFz4gJ/ardh/3NT22MpwIw3K5cI/MdmkkpmcQNuatv8Zv4L4K mPEddhz59LGFNmTGS2hrpMdOfI6svPHyBspjgVdLcFOHF63+hKTAV2Eqvx6l8t+kzqNU +w/A== X-Forwarded-Encrypted: i=1; AJvYcCWL6UIAXsKCqu7vCnYGODWXCUZXp3Dw+ekYwelD4wfrB9Tiw7R3FScFJ2EE1bLgR4TIdmS+nTAnbi0E@vger.kernel.org, AJvYcCWVTR8KUupL72metdZxQ1p1d3+EbZXb2AdLxaPJMQQDFBcCmOewBBuc91l4W1cm+9YDDVQA4FWMvAPktmv4@vger.kernel.org X-Gm-Message-State: AOJu0YwBPq/GDKcU/Gx8neiWSDAE24ekkC9nIJTaW1rW0v/JuVVMI6FA bGK0V6H+bvC+K8PmcmrDj9YbIiFVUS0tNpBNJZzU2tNxse/c9urA304DkCPn X-Google-Smtp-Source: AGHT+IEjI2sgA8ywNtDkFWIWUD1HRdFElMz9OGiERJ1wWXLb7hgIJDdlpCuCcciYLAV0tXU6MiZ3+Q== X-Received: by 2002:a17:906:6a24:b0:a8a:9207:c4c1 with SMTP id a640c23a62f3a-a90d5167dafmr1045761266b.58.1727043489967; Sun, 22 Sep 2024 15:18:09 -0700 (PDT) Received: from [127.0.1.1] (84-115-213-37.cable.dynamic.surfer.at. [84.115.213.37]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a90611164d0sm1126202066b.91.2024.09.22.15.18.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Sep 2024 15:18:09 -0700 (PDT) From: Javier Carrasco Date: Mon, 23 Sep 2024 00:17:58 +0200 Subject: [PATCH v2 10/10] iio: light: veml6030: add support for veml6035 Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240923-veml6035-v2-10-58c72a0df31c@gmail.com> References: <20240923-veml6035-v2-0-58c72a0df31c@gmail.com> In-Reply-To: <20240923-veml6035-v2-0-58c72a0df31c@gmail.com> To: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Rishi Gupta Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Jonathan Cameron , Javier Carrasco X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1727043474; l=15350; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=+q0HZm1fKYjGmC3vzyj1zQ35NDKLymKJHg/syO6dFQQ=; b=pgYmNgExgYwJQGEi4oB3jaDUom+I4WeBMv8s22pwN7/cVg1cet8HES9enfRgd1OxLfLXB6n1Q YuOWWytmKTnD8FCvIPOwo3b/qtElQOnlHVITQr5Mmi2BOke46YZk19I X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= The veml6035 is an ALS that shares most of its functionality with the veml6030, which allows for some code recycling. Some chip-specific properties differ and dedicated functions to get and set the sensor gain as well as its initialization are required. Signed-off-by: Javier Carrasco --- drivers/iio/light/Kconfig | 4 +- drivers/iio/light/veml6030.c | 291 +++++++++++++++++++++++++++++++++++++++---- 2 files changed, 266 insertions(+), 29 deletions(-) diff --git a/drivers/iio/light/Kconfig b/drivers/iio/light/Kconfig index 515ff46b5b82..171ccaecf5b6 100644 --- a/drivers/iio/light/Kconfig +++ b/drivers/iio/light/Kconfig @@ -669,12 +669,12 @@ config VCNL4035 module will be called vcnl4035. config VEML6030 - tristate "VEML6030 ambient light sensor" + tristate "VEML6030 and VEML6035 ambient light sensors" select REGMAP_I2C depends on I2C help Say Y here if you want to build a driver for the Vishay VEML6030 - ambient light sensor (ALS). + and VEML6035 ambient light sensors (ALS). To compile this driver as a module, choose M here: the module will be called veml6030. diff --git a/drivers/iio/light/veml6030.c b/drivers/iio/light/veml6030.c index 19c69bfad8cb..d5c09c148d22 100644 --- a/drivers/iio/light/veml6030.c +++ b/drivers/iio/light/veml6030.c @@ -1,13 +1,19 @@ // SPDX-License-Identifier: GPL-2.0+ /* - * VEML6030 Ambient Light Sensor + * VEML6030 and VMEL6035 Ambient Light Sensors * * Copyright (c) 2019, Rishi Gupta * + * VEML6030: * Datasheet: https://www.vishay.com/docs/84366/veml6030.pdf * Appnote-84367: https://www.vishay.com/docs/84367/designingveml6030.pdf + * + * VEML6035: + * Datasheet: https://www.vishay.com/docs/84889/veml6035.pdf + * Appnote-84944: https://www.vishay.com/docs/84944/designingveml6035.pdf */ +#include #include #include #include @@ -39,16 +45,34 @@ #define VEML6030_ALS_INT_EN BIT(1) #define VEML6030_ALS_SD BIT(0) +#define VEML6035_GAIN_M GENMASK(12, 10) +#define VEML6035_GAIN BIT(10) +#define VEML6035_DG BIT(11) +#define VEML6035_SENS BIT(12) +#define VEML6035_INT_CHAN BIT(3) +#define VEML6035_CHAN_EN BIT(2) + +struct veml603x_chip { + const char *name; + const int(*scale_vals)[][2]; + const int num_scale_vals; + const struct iio_info *info; + const struct iio_info *info_no_irq; + int (*hw_init)(struct iio_dev *indio_dev); + int (*set_als_gain)(struct iio_dev *indio_dev, int val, int val2); + int (*get_als_gain)(struct iio_dev *indio_dev, int *val, int *val2); +}; + /* * The resolution depends on both gain and integration time. The * cur_resolution stores one of the resolution mentioned in the * table during startup and gets updated whenever integration time * or gain is changed. * - * Table 'resolution and maximum detection range' in appnote 84367 + * Table 'resolution and maximum detection range' in the appnotes * is visualized as a 2D array. The cur_gain stores index of gain - * in this table (0-3) while the cur_integration_time holds index - * of integration time (0-5). + * in this table (0-3 for VEML6030, 0-5 for VEML6035) while the + * cur_integration_time holds index of integration time (0-5). */ struct veml6030_data { struct i2c_client *client; @@ -56,6 +80,7 @@ struct veml6030_data { int cur_resolution; int cur_gain; int cur_integration_time; + const struct veml603x_chip *chip; }; static const int veml6030_it_times[][2] = { @@ -69,7 +94,8 @@ static const int veml6030_it_times[][2] = { /* * Scale is 1/gain. Value 0.125 is ALS gain x (1/8), 0.25 is - * ALS gain x (1/4), 1.0 = ALS gain x 1 and 2.0 is ALS gain x 2. + * ALS gain x (1/4), 0.5 is ALS gain x (1/2), 1.0 is ALS gain x 1, + * 2.0 is ALS gain x2, and 4.0 is ALS gain x 4. */ static const int veml6030_scale_vals[][2] = { {0, 125000}, @@ -78,6 +104,15 @@ static const int veml6030_scale_vals[][2] = { {2, 0}, }; +static const int veml6035_scale_vals[][2] = { + {0, 125000}, + {0, 250000}, + {0, 500000}, + {1, 0}, + {2, 0}, + {4, 0}, +}; + /* * Persistence = 1/2/4/8 x integration time * Minimum time for which light readings must stay above configured @@ -386,6 +421,21 @@ static int veml6030_write_persistence(struct iio_dev *indio_dev, return ret; } +/* + * Cache currently set gain & update resolution. For every + * increase in the gain to next level, resolution is halved + * and vice-versa. + */ +static void veml6030_update_gain_res(struct veml6030_data *data, int gain_idx) +{ + if (data->cur_gain < gain_idx) + data->cur_resolution <<= gain_idx - data->cur_gain; + else if (data->cur_gain > gain_idx) + data->cur_resolution >>= data->cur_gain - gain_idx; + + data->cur_gain = gain_idx; +} + static int veml6030_set_als_gain(struct iio_dev *indio_dev, int val, int val2) { @@ -416,19 +466,49 @@ static int veml6030_set_als_gain(struct iio_dev *indio_dev, return ret; } - /* - * Cache currently set gain & update resolution. For every - * increase in the gain to next level, resolution is halved - * and vice-versa. - */ - if (data->cur_gain < gain_idx) - data->cur_resolution <<= gain_idx - data->cur_gain; - else if (data->cur_gain > gain_idx) - data->cur_resolution >>= data->cur_gain - gain_idx; + veml6030_update_gain_res(data, gain_idx); - data->cur_gain = gain_idx; + return 0; +} - return ret; +static int veml6035_set_als_gain(struct iio_dev *indio_dev, int val, int val2) +{ + int ret, new_gain, gain_idx; + struct veml6030_data *data = iio_priv(indio_dev); + + if (val == 0 && val2 == 125000) { + new_gain = VEML6035_SENS; + gain_idx = 5; + } else if (val == 0 && val2 == 250000) { + new_gain = VEML6035_SENS | VEML6035_GAIN; + gain_idx = 4; + } else if (val == 0 && val2 == 500000) { + new_gain = VEML6035_SENS | VEML6035_GAIN | + VEML6035_DG; + gain_idx = 3; + } else if (val == 1 && val2 == 0) { + new_gain = 0x0000; + gain_idx = 2; + } else if (val == 2 && val2 == 0) { + new_gain = VEML6035_GAIN; + gain_idx = 1; + } else if (val == 4 && val2 == 0) { + new_gain = VEML6035_GAIN | VEML6035_DG; + gain_idx = 0; + } else { + return -EINVAL; + } + + ret = regmap_update_bits(data->regmap, VEML6030_REG_ALS_CONF, + VEML6035_GAIN_M, new_gain); + if (ret) { + dev_err(&data->client->dev, "can't set als gain %d\n", ret); + return ret; + } + + veml6030_update_gain_res(data, gain_idx); + + return 0; } static int veml6030_get_als_gain(struct iio_dev *indio_dev, @@ -468,6 +548,52 @@ static int veml6030_get_als_gain(struct iio_dev *indio_dev, return IIO_VAL_INT_PLUS_MICRO; } +static int veml6035_get_als_gain(struct iio_dev *indio_dev, int *val, int *val2) +{ + int ret, reg; + struct veml6030_data *data = iio_priv(indio_dev); + + ret = regmap_read(data->regmap, VEML6030_REG_ALS_CONF, ®); + if (ret) { + dev_err(&data->client->dev, + "can't read als conf register %d\n", ret); + return ret; + } + + switch (FIELD_GET(VEML6035_GAIN_M, reg)) { + case 0: + *val = 1; + *val2 = 0; + break; + case 1: + case 2: + *val = 2; + *val2 = 0; + break; + case 3: + *val = 4; + *val2 = 0; + break; + case 4: + *val = 0; + *val2 = 125000; + break; + case 5: + case 6: + *val = 0; + *val2 = 250000; + break; + case 7: + *val = 0; + *val2 = 500000; + break; + default: + return -EINVAL; + } + + return IIO_VAL_INT_PLUS_MICRO; +} + static int veml6030_read_thresh(struct iio_dev *indio_dev, int *val, int *val2, int dir) { @@ -559,7 +685,7 @@ static int veml6030_read_raw(struct iio_dev *indio_dev, return -EINVAL; case IIO_CHAN_INFO_SCALE: if (chan->type == IIO_LIGHT) - return veml6030_get_als_gain(indio_dev, val, val2); + return data->chip->get_als_gain(indio_dev, val, val2); return -EINVAL; default: return -EINVAL; @@ -571,6 +697,8 @@ static int veml6030_read_avail(struct iio_dev *indio_dev, const int **vals, int *type, int *length, long mask) { + struct veml6030_data *data = iio_priv(indio_dev); + switch (mask) { case IIO_CHAN_INFO_INT_TIME: *vals = (int *)&veml6030_it_times; @@ -578,8 +706,8 @@ static int veml6030_read_avail(struct iio_dev *indio_dev, *type = IIO_VAL_INT_PLUS_MICRO; return IIO_AVAIL_LIST; case IIO_CHAN_INFO_SCALE: - *vals = (int *)&veml6030_scale_vals; - *length = 2 * ARRAY_SIZE(veml6030_scale_vals); + *vals = (int *)*data->chip->scale_vals; + *length = 2 * data->chip->num_scale_vals; *type = IIO_VAL_INT_PLUS_MICRO; return IIO_AVAIL_LIST; default: @@ -591,6 +719,8 @@ static int veml6030_write_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int val, int val2, long mask) { + struct veml6030_data *data = iio_priv(indio_dev); + switch (mask) { case IIO_CHAN_INFO_INT_TIME: switch (chan->type) { @@ -602,7 +732,7 @@ static int veml6030_write_raw(struct iio_dev *indio_dev, case IIO_CHAN_INFO_SCALE: switch (chan->type) { case IIO_LIGHT: - return veml6030_set_als_gain(indio_dev, val, val2); + return data->chip->set_als_gain(indio_dev, val, val2); default: return -EINVAL; } @@ -713,12 +843,28 @@ static const struct iio_info veml6030_info = { .event_attrs = &veml6030_event_attr_group, }; +static const struct iio_info veml6035_info = { + .read_raw = veml6030_read_raw, + .read_avail = veml6030_read_avail, + .write_raw = veml6030_write_raw, + .read_event_value = veml6030_read_event_val, + .write_event_value = veml6030_write_event_val, + .read_event_config = veml6030_read_interrupt_config, + .write_event_config = veml6030_write_interrupt_config, + .event_attrs = &veml6030_event_attr_group, +}; + static const struct iio_info veml6030_info_no_irq = { .read_raw = veml6030_read_raw, .read_avail = veml6030_read_avail, .write_raw = veml6030_write_raw, }; +static const struct iio_info veml6035_info_no_irq = { + .read_raw = veml6030_read_raw, + .write_raw = veml6030_write_raw, +}; + static irqreturn_t veml6030_event_handler(int irq, void *private) { int ret, reg, evtdir; @@ -803,6 +949,63 @@ static int veml6030_hw_init(struct iio_dev *indio_dev) return ret; } +/* + * Set ALS gain to 1/8, integration time to 100 ms, ALS and WHITE + * channel enabled, ALS channel interrupt, PSM enabled, + * PSM_WAIT = 0.8 s, persistence to 1 x integration time and the + * threshold interrupt disabled by default. First shutdown the sensor, + * update registers and then power on the sensor. + */ +static int veml6035_hw_init(struct iio_dev *indio_dev) +{ + int ret, val; + struct veml6030_data *data = iio_priv(indio_dev); + struct i2c_client *client = data->client; + + ret = veml6030_als_shut_down(data); + if (ret) + return dev_err_probe(&client->dev, ret, "can't shutdown als\n"); + + ret = regmap_write(data->regmap, VEML6030_REG_ALS_CONF, + VEML6035_SENS | VEML6035_CHAN_EN | VEML6030_ALS_SD); + if (ret) + return dev_err_probe(&client->dev, ret, + "can't setup als configs\n"); + + ret = regmap_update_bits(data->regmap, VEML6030_REG_ALS_PSM, + VEML6030_PSM | VEML6030_PSM_EN, 0x03); + if (ret) + return dev_err_probe(&client->dev, ret, + "can't setup default PSM\n"); + + ret = regmap_write(data->regmap, VEML6030_REG_ALS_WH, 0xFFFF); + if (ret) + return dev_err_probe(&client->dev, ret, + "can't setup high threshold\n"); + + ret = regmap_write(data->regmap, VEML6030_REG_ALS_WL, 0x0000); + if (ret) + return dev_err_probe(&client->dev, ret, + "can't setup low threshold\n"); + + ret = veml6030_als_pwr_on(data); + if (ret) + return dev_err_probe(&client->dev, ret, "can't poweron als\n"); + + /* Clear stale interrupt status bits if any during start */ + ret = regmap_read(data->regmap, VEML6030_REG_ALS_INT, &val); + if (ret < 0) + return dev_err_probe(&client->dev, ret, + "can't clear als interrupt status\n"); + + /* Cache currently active measurement parameters */ + data->cur_gain = 5; + data->cur_resolution = 1024; + data->cur_integration_time = 3; + + return 0; +} + static int veml6030_probe(struct i2c_client *client) { int ret; @@ -833,7 +1036,11 @@ static int veml6030_probe(struct i2c_client *client) return dev_err_probe(&client->dev, ret, "failed to enable regulator\n"); - indio_dev->name = "veml6030"; + data->chip = i2c_get_match_data(client); + if (!data->chip) + return -EINVAL; + + indio_dev->name = data->chip->name; indio_dev->channels = veml6030_channels; indio_dev->num_channels = ARRAY_SIZE(veml6030_channels); indio_dev->modes = INDIO_DIRECT_MODE; @@ -842,15 +1049,15 @@ static int veml6030_probe(struct i2c_client *client) ret = devm_request_threaded_irq(&client->dev, client->irq, NULL, veml6030_event_handler, IRQF_TRIGGER_LOW | IRQF_ONESHOT, - "veml6030", indio_dev); + indio_dev->name, indio_dev); if (ret < 0) return dev_err_probe(&client->dev, ret, "irq %d request failed\n", client->irq); - indio_dev->info = &veml6030_info; + indio_dev->info = data->chip->info; } else { - indio_dev->info = &veml6030_info_no_irq; + indio_dev->info = data->chip->info_no_irq; } ret = devm_add_action_or_reset(&client->dev, @@ -858,7 +1065,7 @@ static int veml6030_probe(struct i2c_client *client) if (ret < 0) return ret; - ret = veml6030_hw_init(indio_dev); + ret = data->chip->hw_init(indio_dev); if (ret < 0) return ret; @@ -894,14 +1101,44 @@ static int veml6030_runtime_resume(struct device *dev) static DEFINE_RUNTIME_DEV_PM_OPS(veml6030_pm_ops, veml6030_runtime_suspend, veml6030_runtime_resume, NULL); +static const struct veml603x_chip veml6030_chip = { + .name = "veml6030", + .scale_vals = &veml6030_scale_vals, + .num_scale_vals = ARRAY_SIZE(veml6030_scale_vals), + .info = &veml6030_info, + .info_no_irq = &veml6030_info_no_irq, + .hw_init = veml6030_hw_init, + .set_als_gain = veml6030_set_als_gain, + .get_als_gain = veml6030_get_als_gain, +}; + +static const struct veml603x_chip veml6035_chip = { + .name = "veml6035", + .scale_vals = &veml6035_scale_vals, + .num_scale_vals = ARRAY_SIZE(veml6035_scale_vals), + .info = &veml6035_info, + .info_no_irq = &veml6035_info_no_irq, + .hw_init = veml6035_hw_init, + .set_als_gain = veml6035_set_als_gain, + .get_als_gain = veml6035_get_als_gain, +}; + static const struct of_device_id veml6030_of_match[] = { - { .compatible = "vishay,veml6030" }, + { + .compatible = "vishay,veml6030", + .data = &veml6030_chip, + }, + { + .compatible = "vishay,veml6035", + .data = &veml6035_chip, + }, { } }; MODULE_DEVICE_TABLE(of, veml6030_of_match); static const struct i2c_device_id veml6030_id[] = { - { "veml6030" }, + { "veml6030", (kernel_ulong_t)&veml6030_chip}, + { "veml6035", (kernel_ulong_t)&veml6035_chip}, { } }; MODULE_DEVICE_TABLE(i2c, veml6030_id);