From patchwork Fri Sep 13 13:18: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: 13803441 Received: from mail-ej1-f50.google.com (mail-ej1-f50.google.com [209.85.218.50]) (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 1FCB71DA608; Fri, 13 Sep 2024 13:19:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726233559; cv=none; b=kIZ85RXYv3n4LNb+fCwjbnxB3B89ekjF2bIS+cTp69wiAo45FqMhJOfbQjvmcMMCeIlQaz+PWjCggaHFykKFXbxiVQlHJk8ar6FpLEPmha2Em6aJQL09+uHskOvgRab2oOyAm8uGesdtYj/UQtjRafJHDLWaCqHrswz8wgBasz0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726233559; c=relaxed/simple; bh=+Hq6cocZ/5AtfkYSuQkKBOiTzXaI16eJzX+aMB/nzDg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Xtm1Bufv/0xJFol6/t0EGbxRWV+1u2QCFi8pWrn1pS9YpcLhDjgXw/LGYbM3tO1J4cApCLVHMren1MlSPfrh/xR8O0DlmsIq/GbfoeQgdoUwIxhL31Kuf+LXZLuGakqu9BMJCbHP2NT3n5Tfhhjozvclg1PUgcde0QKA8H89LgE= 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=TC2vJYUI; arc=none smtp.client-ip=209.85.218.50 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="TC2vJYUI" Received: by mail-ej1-f50.google.com with SMTP id a640c23a62f3a-a9018103214so292049266b.3; Fri, 13 Sep 2024 06:19:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726233556; x=1726838356; 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=nKGg1JqyQ8tWRXFIr3jOiwTzcFxMss2m/MiwvVX6Dgc=; b=TC2vJYUIuSDL62OQ/J5QwdGEC+G3Dhf/xPgZT3RDsFy2GYw3qhnjGBUo/YMo49grnS 18QH5/Q17TsXLOizrfyzFVp9KYBqrcgJ7a8F9+CRiOCPlOxhlH0h11C1G57mohIfodUt P7dwTFggwdKqTn4otGWz+tsXzcPFSlHdnsZ2VDwJjqPr/h/ETsJpREil5hZ5rLk6vCba 9Cvw5/jXSje04CDgjcceqTmRRijpr6DvgwkIoWQkFbw/Qgsgg7AhJcmXJzW/7P/YExej uNEkDYwfT4v/r+oOOoDE5krFi0xbmag7H7h7Z7Vkr49Xj6TkUOOB8sjNfQVNP965YF/h 4lfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726233556; x=1726838356; 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=nKGg1JqyQ8tWRXFIr3jOiwTzcFxMss2m/MiwvVX6Dgc=; b=aPj90rQeuggqY0GgwGUa0+dT2e+ERMyCi1LOXZ0aP1B1Ap35H/j45Hf4TK3H4EWIUZ l28M5vky8FCjOIzRBbGd7A6nnl5/6uDpPXct8lhsbwPv4xz6+G86kCddQxuBu2nv8Eyr rT/fu4PlQi6QjdnN+V4Pa7dAm4jaPguZeBSyygMGzyg1EllvptMQUq+O0ckL4RK3pI1Z 0tIOyYJHpCS16RgfPis3w4sB20O9a5tMThxzmJXXF6HfrQ8obgp6Ergd51fgIUUYARCc q8hj/V2M4Bzkxfth6xBoq9LSZmMGrSpWR+9ZbaaCOb86/coEvrOO2ApZOXxQ9ILSl6p5 FGeQ== X-Forwarded-Encrypted: i=1; AJvYcCU2c2805A3HT2O1zpbLbRaa87rz/q7nQtsJH/LydL0yuKKarnqwCJEQ+knbrwlfKU51vO2G2koR+nhM@vger.kernel.org, AJvYcCX4BPa4t8TI+1Hhh4L1rDQJTArf/B1B4TfUj6Ma/jH5+HPGnHBOfFPFPjYqDl4NSNOF9ZxRWxK3RS03ADJu@vger.kernel.org X-Gm-Message-State: AOJu0Yxom66ki/GEPtlhxwpnCMXc1PtV5QyjbLP3mRqRUiuC7OtUfDFI xOLCDm623rcrhP0yr2r7WtwBcbtn0BlChHb4tR9ffsKghnq2uFUB X-Google-Smtp-Source: AGHT+IFr8l1a1r45CMGOdwRmurG37EDnGUOfBcE+5dkkO6Z/OLUikX7U8qjWpRWox28cmPs9IZ+pGw== X-Received: by 2002:a17:907:868e:b0:a7d:a00a:aa02 with SMTP id a640c23a62f3a-a90293f9003mr524615966b.1.1726233556188; Fri, 13 Sep 2024 06:19:16 -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-a8d25a258a3sm865945666b.89.2024.09.13.06.19.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Sep 2024 06:19:15 -0700 (PDT) From: Javier Carrasco Date: Fri, 13 Sep 2024 15:18:56 +0200 Subject: [PATCH 1/7] dt-bindings: iio: light: veml6030: rename to add manufacturer Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240913-veml6035-v1-1-0b09c0c90418@gmail.com> References: <20240913-veml6035-v1-0-0b09c0c90418@gmail.com> In-Reply-To: <20240913-veml6035-v1-0-0b09c0c90418@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=1726233553; l=1065; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=+Hq6cocZ/5AtfkYSuQkKBOiTzXaI16eJzX+aMB/nzDg=; b=Gjb9se+F8+f1BU+q8vTIi7eghER/+m/DuN3+9/efO08l5hFALil9W+0rO0lx29geG/GidM6qD k0lRYHh76/aCNUkHtdPNmd0jMsbDqJcCb7pcSHBfpzlCg48yhHUdyQ3 X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= Follow the common pattern manufacturer,devicename. Signed-off-by: Javier Carrasco Acked-by: Conor Dooley --- .../bindings/iio/light/{veml6030.yaml => vishay,veml6030.yaml} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/iio/light/veml6030.yaml b/Documentation/devicetree/bindings/iio/light/vishay,veml6030.yaml similarity index 95% rename from Documentation/devicetree/bindings/iio/light/veml6030.yaml rename to Documentation/devicetree/bindings/iio/light/vishay,veml6030.yaml index fb19a2d7a849..7f4995557570 100644 --- a/Documentation/devicetree/bindings/iio/light/veml6030.yaml +++ b/Documentation/devicetree/bindings/iio/light/vishay,veml6030.yaml @@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0+ %YAML 1.2 --- -$id: http://devicetree.org/schemas/iio/light/veml6030.yaml# +$id: http://devicetree.org/schemas/iio/light/vishay,veml6030.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# title: VEML6030 Ambient Light Sensor (ALS) From patchwork Fri Sep 13 13:18: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: 13803442 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 B1FAC1DB535; Fri, 13 Sep 2024 13:19:19 +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=1726233561; cv=none; b=KaLGtBNsEpw1lS6At5JE2kxgccVLnkcgIZfMNnE4yJCDtuijqXfip4KMicAhQJgLHYWuSyApnGODY05lkLeh7JSPqiMvgfCHIbhpd2hQiJCPp0NHQb4ohMI7ABvzCWlw81QWQRxfpXH/maPv/C+9LSgEKzECAlvX+lBGCWL4VBg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726233561; c=relaxed/simple; bh=QxTQNvrLxkh1mF26QIuMBRqrU+ZhcDmuI2kAxhFttkg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=bxUe6MKlA/RSbkfwFZtxpZFE8NsFgyHNA78PNv7VhJt5hUWMPvh9sWySvA0cTkuroE7aimgdxibMnQMLrGzv/LbUbsHv4yPgIgAdn5ZksJziI5CiuWxyMcC9Hq8SIwPqrysLuxGSyPytxnb7PCLAs9JagKboN06PC+NH3zu7GgI= 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=VI6xo8em; 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="VI6xo8em" Received: by mail-ej1-f46.google.com with SMTP id a640c23a62f3a-a8a7b1c2f2bso331671466b.0; Fri, 13 Sep 2024 06:19:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726233558; x=1726838358; 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=FvCncG6LHLyyoaSgVvqTRJYitrtjvsDOL7xX1DcIzHI=; b=VI6xo8emk0y1PnyBuXUZ2C3cSGW3r0mKqn0d6DkXddtUktx/OQdVziyVGvpqfJU1SQ 8fb3nBCJunZdkMemF+hfL0iUTC0vi7dOVyn9jjmiiP4KKZOcagctMz6rfALNO3ntc8s3 hr2borEhnNDUeqD/RnCPTNfRQEY+SSGHUwUMHng4lmKZMoiNpK1JRi23sQFsiKvFArwZ yxhijDv6UvCOG+WNOH7vtQ+pEzYk0Zr86DOuu6ZLfX/aTGJkB8JA1nLiZPw+1t1Nlu4p 94We3Rab0ypOkMtYBepJ44JvrCXd5iLazgWhfMQvO9glKFf9+fFZFfMPB9SlZlEp70On fcfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726233558; x=1726838358; 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=FvCncG6LHLyyoaSgVvqTRJYitrtjvsDOL7xX1DcIzHI=; b=f0/s72mMSwuVSU6hV2qzok5Ye5336fZJ/3FgjkHddAc9INgeiz5IEsWSyfQC/VHLbZ 5Bv1jvNu5c6LPo1xolhVFF5/sTqqZLoQme2wQekk3XIxqKUo2glK9PCMuCCHRtnXyaHS M788PSdXNt8EQibUqMCa1/DRlpuJ3CBamnFx+1rvKcV6Qqq+C3p5bO9GMyeQzgzJWHtB C1J4vbxCDh+QarmJK1XJDyRYq3XTas704sKLc4vFXrxjyQbsqZZ7tIgd302ec9qvLRUt eMzZCsPEAJQHHxR7XiT628wqCZxOevFPr3r7NwHsqWL4gdYJJt8YU4ujpbN77hiZl3Ff CZbA== X-Forwarded-Encrypted: i=1; AJvYcCUo+OgWGNgLC4lkyggSVpfhpgBSUElvcCwvTV7cSvc5XXtcsFvOX8OVvQ71JnRpoKJYp1EgA/Mctft1Znv3@vger.kernel.org, AJvYcCXx4pa6KmtsoLWgh5E4xOCszvEzpJlyRaoBpRWGaGVlVsLHD5/+zilLnXpM9tIRANSWzmiLUD5berFt@vger.kernel.org X-Gm-Message-State: AOJu0Yx1Ld+fbqybOIdMPOANusinYtZZm8H+AAIsSV7YwIrMSpXWoYdP plDYbzueE0Kwh88np5wFbrnq5MkNM8Y0M/MFYElcv7cxHlsih5Ok X-Google-Smtp-Source: AGHT+IHvHlAyalGXsjJDX7CzVRuDNtVhq3dY80xNEnWGKjx5/caV7+QaAtWAxoVtguLJAcBdQpBYYQ== X-Received: by 2002:a17:906:730d:b0:a7a:a46e:dc3f with SMTP id a640c23a62f3a-a90296eabc9mr732776166b.45.1726233557603; Fri, 13 Sep 2024 06:19:17 -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-a8d25a258a3sm865945666b.89.2024.09.13.06.19.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Sep 2024 06:19:17 -0700 (PDT) From: Javier Carrasco Date: Fri, 13 Sep 2024 15:18:57 +0200 Subject: [PATCH 2/7] 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: <20240913-veml6035-v1-2-0b09c0c90418@gmail.com> References: <20240913-veml6035-v1-0-0b09c0c90418@gmail.com> In-Reply-To: <20240913-veml6035-v1-0-0b09c0c90418@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=1726233553; l=2738; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=QxTQNvrLxkh1mF26QIuMBRqrU+ZhcDmuI2kAxhFttkg=; b=gg2z2BzG1e7LXQfbyKLt2/n6StFumXHAGLcTiRsIr+nDhRzREUEEs/yQPpFtSOBeQl5aBz0Gg NbRkyzwCs/hDElpBjlDKNu2qo3E9WpejParnL9WY+BcMI4sS9Y8qfRP 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. Signed-off-by: Javier Carrasco Acked-by: Conor Dooley --- .../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 7f4995557570..f88e043d7ede 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: @@ -45,6 +43,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 Fri Sep 13 13:18: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: 13803443 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 A58951DB555; Fri, 13 Sep 2024 13:19:20 +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=1726233562; cv=none; b=dWj1NEnyOmzhB+kpebR57sRu6tv8QyK8vdddbL9/ycDw+jx3p1yuHd1GAJXtKST3H15kDAaVhiiyxLtFegcO6g/uzU24SxG3qwUL+ILOOhsU2BPpGbnRpNkzuyuVk9FADYUUyoL4sJxgXsZT4V70si0lM2uwoYANfMYhnkua7uU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726233562; c=relaxed/simple; bh=1o+RujVAQZnAD3qfV2O0LLel9fgxe9gwMp5ZPSdYRNo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=iX9+cRiZG8K0q1HwXm3CBUyuP4cQ9uB1FOxoPnWt3FcA9fJdR/fsdcS4CayEFicyLhWw6pT4ffud3xNOOrnkHULBT3vd0lBLp6ZYBJy4WCHn4zEw35RndqCftszxJgej974r32XvwuQEdvIrAvZmgGQ8ns+OjEdmilMZbxyASWg= 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=iJOhsmTB; 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="iJOhsmTB" Received: by mail-ej1-f44.google.com with SMTP id a640c23a62f3a-a8a897bd4f1so107321866b.3; Fri, 13 Sep 2024 06:19:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726233559; x=1726838359; 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=5IF4qGvII+dur0qzTSrxsUrxH0fWjZLIM0pUAGbbih0=; b=iJOhsmTBwGSL4eqoxDINnseAAiO+hxFkJ1LddtGNUpzPfk6pTLeS1agxUMin7Slg1Y nEBX/yqTTs4Zh9OCnXy/waER8parEEHs1DA94NoZqbN1QCn+pTZaM7tprEE61ZlKge/p 9cCct4A/a40NGFh9JSKsJAFkU0n3syoDUI13dmzZ2eWaQ8zincyUO5jTSkHJxBorUEJO eykxHYEEh6p9GI7vvxUoAWdVDtcVjkVpGsQLlWfBiuykMJQmMg0/M/D1Acmp0/RJIXM5 B3Y61QkdZfz8dZmX9jTnrBgVula1acs6BM4pPBcY5lL8XoCiQXHzwt0NfaG/zUPYqhBH xKeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726233559; x=1726838359; 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=5IF4qGvII+dur0qzTSrxsUrxH0fWjZLIM0pUAGbbih0=; b=EX1V0RkiYgRxOgseft9SYu0A7JjynaVo7pTYcy64kxMQIh9ZAD2dOHMr5IUcdVVUa8 wvFUv57ojBYCb4g/KylT+hIxhK1nUaauqYoMfyR2bnoxp3SQE1WuMIrVp6wD+9TdDrbD h3MJLG26Ds2gXRT33rWW6DzntLV26diQcXwqfd8SU/MvVMoKjCQ8XQl+rndrj2uJcW72 xJvM41plxUDpbn84ztJjGbEO8cZM8FJ4VpTK2UUxHqvad1fo02jR3sM5dveuwlOO04dI OvQ9M7otUw8RMM+XRoUp+kY0mCXB3wyFCoBS668TBlChP7cgZpKfl2/gb0/rzgjM+Hpe bO1Q== X-Forwarded-Encrypted: i=1; AJvYcCVD14xrwnl3WerRAR2Lfs6X72JphwtCer5h9gaj3FRWE10LLcFKo8NygPGDYy60WLkPa9X1NL7IMrNYKpWd@vger.kernel.org, AJvYcCWkVogmzK2FBrOwlyULkPqbYEDuJ8EHabiqV0TTmqBULULpJ/vTo+P0316eSGoRU+EA6DL9abeH@vger.kernel.org, AJvYcCXztUHOiFbuRZG6Igjd/klPvU6ZcDOWusJFhxMTHZiPYZg9ZY1ngwOEnB4QyC41MCAJt76hbMS7d2Cr@vger.kernel.org X-Gm-Message-State: AOJu0YyLZ3vU+hKwO81yqYRL09lX3Dil7/vjJ0Vdo1GFWG2eaFmeYfU2 nLwC7F+9XJUZYt15GAX7e3sQL+W6ReOYbbBtWTO5/yU0LhyT0nEZ X-Google-Smtp-Source: AGHT+IGls/PJoarlAbHcGQA/sOJ/gjWdxcBKwteEvQzmyudaC7u8D3sWcLe/9CjdeJO4QCbLfDuWTw== X-Received: by 2002:a17:907:60d1:b0:a77:c30c:341 with SMTP id a640c23a62f3a-a904758f269mr225921266b.0.1726233559073; Fri, 13 Sep 2024 06:19:19 -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-a8d25a258a3sm865945666b.89.2024.09.13.06.19.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Sep 2024 06:19:18 -0700 (PDT) From: Javier Carrasco Date: Fri, 13 Sep 2024 15:18:58 +0200 Subject: [PATCH 3/7] iio: light: veml6030: fix IIO device retrieval from embedded device Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240913-veml6035-v1-3-0b09c0c90418@gmail.com> References: <20240913-veml6035-v1-0-0b09c0c90418@gmail.com> In-Reply-To: <20240913-veml6035-v1-0-0b09c0c90418@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=1726233553; l=1569; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=1o+RujVAQZnAD3qfV2O0LLel9fgxe9gwMp5ZPSdYRNo=; b=qnqEVdzyMlkDlPv3IGJ5UBVq48lMpPTlZpPD+gPuneJcVhNhh7lDifOVYEfLYL6/sMphF5oe1 7+hBxFB4fX/CZ+SpmC7WZUZHftW+GNNzYTKpD3hrBZehd+c/gxvUiL+ X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= The dev pointer that is received as an argument in the in_illuminance_period_available_show function references the device embedded in the IIO device, not in the i2c client. dev_to_iio_dev() must be used to accessthe right data. The current implementation leads to a segmentation fault on every attempt to read the attribute because indio_dev gets a NULL assignment. This bug has been present since the first appearance of the driver, apparently since the last version (V6) before getting applied. A constant attribute was used until then, and the last modifications might have not been tested again. 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 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/iio/light/veml6030.c b/drivers/iio/light/veml6030.c index 2e86d310952e..df2ba3078b91 100644 --- a/drivers/iio/light/veml6030.c +++ b/drivers/iio/light/veml6030.c @@ -99,9 +99,8 @@ static const char * const period_values[] = { static ssize_t in_illuminance_period_available_show(struct device *dev, struct device_attribute *attr, char *buf) { + struct veml6030_data *data = iio_priv(dev_to_iio_dev(dev)); int ret, reg, x; - struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev)); - struct veml6030_data *data = iio_priv(indio_dev); ret = regmap_read(data->regmap, VEML6030_REG_ALS_CONF, ®); if (ret) { From patchwork Fri Sep 13 13:18:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13803444 Received: from mail-ej1-f45.google.com (mail-ej1-f45.google.com [209.85.218.45]) (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 626171DB950; Fri, 13 Sep 2024 13:19:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726233564; cv=none; b=QJ54+ghxvXTSZ/I3hordMRtd7EP5vRZyjeq+G64SXXeFORGNeJmUDB+aRdCx2qHCZYTfottvmFNNwK/OCEOrRgOXFMm6RuS9FglyHwbnVNDRm3iM1y6RGqe+I2Kv3apuNYWH+EJ+RxD/4poRrBmt9AwPS8WXCq2nRAXzw5g3pkw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726233564; c=relaxed/simple; bh=hQa3NqtaF4hSnoJYvqyk19IgtdrMWznpl4mBDkybv/g=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=bfRLUuFxfoqZ74P3vFJbBsM+Az2CP8Nol8gdngiMmhogDoQ8aB/mgsf8BeVm5Bi+oH8/IQ6EycCJyIwY7NdcbcFpWY+kPZBEP+v6QKjWlXPBfNrIEOIcwyWzY++1TnQYpUmjXq1q6TwwQfe3jxCXDH1001jCh9w+8MfboXr9MuU= 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=VMXC7P5/; arc=none smtp.client-ip=209.85.218.45 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="VMXC7P5/" Received: by mail-ej1-f45.google.com with SMTP id a640c23a62f3a-a90349aa7e5so217914166b.0; Fri, 13 Sep 2024 06:19:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726233561; x=1726838361; 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=46WuIa6Wg4WuPmTf2aI2/nmOazVyUrvPtKQX6LQo0+Q=; b=VMXC7P5/950oUNs9rIkk9pjyb5FhiauRAa/yHs1qkg+k/FsHJ5VXnWeBYHDNWF11np VNVEQ2d0OvwAc819CrnXZKGJpdImuDCcuBw6eAYnWxeIlgx5Mc5N55uTQjy1itXnCJ8e YJjFClwqDdg74oZNcdmQvMnZI6XhZch08aauUIPsM0zaVtJ196Rc22Jc4bJXm4yTfyss fyvSB1efPrZXOlwyZ7v2u0OgWouK1e2HbFtgmg9bIj6oFB3QM1W9W9lyiV2j8LPTrdd2 a7ILlJ6pvVGZLkwKAYzWhKigLYZUV8HfsUdtkONVUG2PB8M0lz+1Fj+YEAZZZNZnUyOM Icpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726233561; x=1726838361; 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=46WuIa6Wg4WuPmTf2aI2/nmOazVyUrvPtKQX6LQo0+Q=; b=LH5klbNmte4pf4EfZkfpV506YETHPoIFO2Vbr57EVDDnBEWkK8gfNo46YNOFX/OUqh DXgGofqjvcLBWzEa+rlGyiO1VkJm8mAzEjEhm9RgkOtFMqjQEopY/GJqfawjjQJp7g/e ucOtxbXI7TEXN5AYk/HZ1SD90gP3Ehbco3WiqFM/W7AH1eyaw8iUxkS2E/A5qrcrnm8V ke2ZSnvzzf8YHDnMePMya2A70RSaDKMDgPU0PICJWS+XlhOoKWB72YFWRNr+etFTVLbe NkWfF3rhTw1xy/YQKhX7PNTrkbGE89rwHbrpoIX9ucimirF1lmQTrYnNSSdhRUgDsm5M zsaw== X-Forwarded-Encrypted: i=1; AJvYcCWpdCl8ob7D2T+1fE8/4WhG8LpcbK8rvEBmoTN+54HnrS0WuwdhdZL/ml14lQbTbwgEpmXSNH0mvA9WC/u4@vger.kernel.org, AJvYcCX/hhEClrnbRW+JysZdOr6Iu7sBxxP4JCym4HvZtTrGPI48sIg9UAAQtHQk1piz1vN4tYFT5AbpBdn3@vger.kernel.org X-Gm-Message-State: AOJu0YxMAveuQ2Dk8ZERqaaWdyJobzQXuHthoOUd2dJaM+hxB+2/540Q ct0m6K4urxLSaEpLSVb6380rShqujOxA+Lmx179UNfBisyUOsQsf X-Google-Smtp-Source: AGHT+IEY20oVwxvOlLsWhyJwtNYaUv5yoOmPqv8cwwggD0e16zrCrRahKkf9ii4oomxWng2SAXSdLw== X-Received: by 2002:a17:907:e6a5:b0:a8a:5bfb:7d1a with SMTP id a640c23a62f3a-a90294adcf2mr526534866b.35.1726233560500; Fri, 13 Sep 2024 06:19:20 -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-a8d25a258a3sm865945666b.89.2024.09.13.06.19.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Sep 2024 06:19:20 -0700 (PDT) From: Javier Carrasco Date: Fri, 13 Sep 2024 15:18:59 +0200 Subject: [PATCH 4/7] iio: light: veml6030: make use of regmap_set_bits() Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240913-veml6035-v1-4-0b09c0c90418@gmail.com> References: <20240913-veml6035-v1-0-0b09c0c90418@gmail.com> In-Reply-To: <20240913-veml6035-v1-0-0b09c0c90418@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=1726233553; l=846; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=hQa3NqtaF4hSnoJYvqyk19IgtdrMWznpl4mBDkybv/g=; b=u62XfMUfN0ZB9Jd1+cnH/5PqbJX07x9nPtSKv5fN2e0VLykLA0yTmFajgmTC2PsuU2nEGJyI2 5yyVkTYrUYpAtjmUfF12lSToXFh9oqzD3ZKvmsUQzSF0tRH0tAkvpMQ X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= Instead of using regmap_update_bits() and passing val = 1, use regmap_set_bits(). Signed-off-by: Javier Carrasco --- drivers/iio/light/veml6030.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iio/light/veml6030.c b/drivers/iio/light/veml6030.c index df2ba3078b91..5d4c2e35b987 100644 --- a/drivers/iio/light/veml6030.c +++ b/drivers/iio/light/veml6030.c @@ -149,8 +149,8 @@ static int veml6030_als_pwr_on(struct veml6030_data *data) static int veml6030_als_shut_down(struct veml6030_data *data) { - return regmap_update_bits(data->regmap, VEML6030_REG_ALS_CONF, - VEML6030_ALS_SD, 1); + return regmap_set_bits(data->regmap, VEML6030_REG_ALS_CONF, + VEML6030_ALS_SD); } static void veml6030_als_shut_down_action(void *data) From patchwork Fri Sep 13 13:19:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13803445 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 C97DA1DC053; Fri, 13 Sep 2024 13:19:23 +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=1726233565; cv=none; b=pxqrN4BQO9zF9PiWiRx3RKWBZtfqv77WiJU5BEMc1ibsSs56/GBYjgLBvE/gh/8O0jRTEUh2z8pPHZ9PKR6z+ER9oK0zXj1tw7RULkLqTNLYlbfGPxseH5zlCmsGLGqrfPaRd2gpo0q0DbkqiUsMFzApgP9WRFrrBBA9hRa2yRc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726233565; c=relaxed/simple; bh=85e+X4xDHQ8G/+GRgrGhA5QTajN49KeRr+ftQm+Z52Q=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=QowXImKfIDA22pzZQJmk2mNTKVuFRSa8FQ6F/KztnqI0AIiHbfKTkXidyaw61iV4QjTETaVwN8In72sKbItEhnDa2TLAP7PnwSKa6Nt5GVYFppSawX0jknh2BtQXHOijk0gfkbI3Pd9VfchalrlaA5w9pdz5eH3Ac0NlPfy+3t0= 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=DXYAVmJs; 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="DXYAVmJs" Received: by mail-ej1-f47.google.com with SMTP id a640c23a62f3a-a8d60e23b33so265113466b.0; Fri, 13 Sep 2024 06:19:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726233562; x=1726838362; 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=LORptDXk4Y1iRqE/7SK2ZpJpXJQmX7uETBnq/7nMKgA=; b=DXYAVmJsTF6vMvHO2PYpmMJ0H0qEe+y4ljqJEDi+msxOo4c4Lpv5RsH+1kwd3CtU9/ W0foLGvlh9X+6Y3t0xKK3QHhO9BCURvIPEHjBUDACDgK/qPK/JpJKiRSkUwTsGHeu/Kr 6DZm3lA1pP34TRt1VB0qt8EA/VnqFDremSwJFGEJI2OCvtoj3TyVaNrwyBNet3cmVdNF XtNtpK6Kkd07P42DI9lphd8vyQFVW31W0/a3+F0jOr91kJ5V3e35+mlgCVvquUH0ubzp XJAVLgZ4XCXB4P+c5KiwuCAuwzoXUwHF9FYC3zkLjHIU+20PaCByiAw8NZuSYNHgrOrV izuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726233562; x=1726838362; 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=LORptDXk4Y1iRqE/7SK2ZpJpXJQmX7uETBnq/7nMKgA=; b=Oudt0NMYlRVID9alTAMj+qsNCdnB2DaZFKLmSvKbqmRFJDyxhFjmQs1buXVS/0VAJq QlVlzYZvbFReeL8aDkGBV4BG2cjheMKDlGGO+GqGdOTl0/w7DfnPcWx5NOw7rrmPvawa OUgCZIk5ZtMTBGBMYzR9sijdggh7L+bdt3BCYvPAIEoyS+3jGL7us8tmVvuMwsJxTgRM 3PS+LdT9/wLX68cuhnE7BoBSkFRCY8wMM3N0lFGTzM/OCFMMUA4TisSdSzxK9BkZ4gB+ cfkCVZO6KH6q7Bpf42kndWaRU58oE5Bdy8sy09lodGEM3t73qpPUFImR4MvX1zrf7mh5 Tlug== X-Forwarded-Encrypted: i=1; AJvYcCV4h06InsAFiya9RXI86MuZWRo0kxW24YtY3DWosXqFkrpBzeL/ZVXVK8GvB4CPkWuJ9GoK6fDHHJ+daW23@vger.kernel.org, AJvYcCX4aBIp49eP1vfvGgIXJxTcNBiXMuIvrgL21Tshjgau67MasOznxkhQsoT3G1tCtrzSjS+Vzx6tQSJB@vger.kernel.org X-Gm-Message-State: AOJu0Yx4xAdcbRjQ5HEBdtlXVh950byEzVt8C+ZTM0yR4GwgNsIRw3BV ffoW5nknso8ivql9FVlLkR0y1J8eE7rpABrw+daX4QUaw6WZ3+rJ X-Google-Smtp-Source: AGHT+IHDq4jgzjcLqTc3/uOVIa0kkv2MFxp8aHNHieRdheewDs1UobJxoiqK3kT39Ys3PwOX9BSQCw== X-Received: by 2002:a17:907:3f93:b0:a80:f81c:fd75 with SMTP id a640c23a62f3a-a902910072amr642109466b.0.1726233562108; Fri, 13 Sep 2024 06:19:22 -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-a8d25a258a3sm865945666b.89.2024.09.13.06.19.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Sep 2024 06:19:21 -0700 (PDT) From: Javier Carrasco Date: Fri, 13 Sep 2024 15:19:00 +0200 Subject: [PATCH 5/7] iio: light: veml6030: update sensor resolution Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240913-veml6035-v1-5-0b09c0c90418@gmail.com> References: <20240913-veml6035-v1-0-0b09c0c90418@gmail.com> In-Reply-To: <20240913-veml6035-v1-0-0b09c0c90418@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=1726233553; l=1170; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=85e+X4xDHQ8G/+GRgrGhA5QTajN49KeRr+ftQm+Z52Q=; b=p/zCkIQzTjDLy7kWj9BMmZj3PptIel0XilWJOs6qx/LCE4b1Ndbgvn7cIFpYdUmcPHpL2+CS/ hss4Qgzkex+Drjen88FN+IZ86jgS9FUvLjNnkH3B/uLmtbXBgI8XOrh 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. 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 5d4c2e35b987..d5add040d0b3 100644 --- a/drivers/iio/light/veml6030.c +++ b/drivers/iio/light/veml6030.c @@ -779,7 +779,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 Fri Sep 13 13:19:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13803446 Received: from mail-ed1-f46.google.com (mail-ed1-f46.google.com [209.85.208.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 390B11DC07C; Fri, 13 Sep 2024 13:19:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726233566; cv=none; b=b/l/Rpd42XCHA+7MDdH9MOHk+tfVFcMDpJ1aHuA0iJyXZwY2mQwty+SRcpvtSmTeZJeHfZz0aTYwsCnIq+IzCWkf9K4HKRQFcs8ng/WfrbFsxc/Ersb9vS4b25n6uYmnDhrvU7v+54SfltKDjhxlTZFZ8qtsYujFW0SxdQm3V+c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726233566; c=relaxed/simple; bh=c0ILQnyW+ImdjeGc6T+fx6mOz4Ws/4vgy5ONpaMk9/4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=W4XagUcHshmehWkbeYk97h3Gr37aNPILVqJpn8hyFsiE20EGrEiH02d5Imy8qD7ctG0bNgwzWB/JZ+feEu/r3p6ZIQ/6wX6X7uAihD4LRfOfR59bOMu9OQ1xfTOpLW07H2XQDbz3GfMOAPrOHkbH5f3OFwJEsvqkHcTSP/DxBiU= 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=V7ric3eV; arc=none smtp.client-ip=209.85.208.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="V7ric3eV" Received: by mail-ed1-f46.google.com with SMTP id 4fb4d7f45d1cf-5c3ca32971cso2663246a12.0; Fri, 13 Sep 2024 06:19:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726233563; x=1726838363; 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=gg/pJfNPr78lVbZX5142nrf+6p/6HmhJkcXZ0Cm+gM4=; b=V7ric3eVMLQAfqw6IyIt99CBm0uBGQe1VKTXu9dBt9e1m6rlZroxnpcy0udtJ39tyF N1oRU8PT/TAb1iQoeXQPsJANz35URNR8fpxnHWv+gJfyMu4lpkLx5LBTCUl2S2UXHLq/ sEnD1QqFcFxw6ca92TRAzZ2NDiD5jTdGARhSICwv5r1tAff3AOs8VYpwSUAPfG304v7G oEWQeFOw3dW1yqVzrnEN9adXtoXwpXzOQGxRZfbHjpk+48Xwj5SixFTOCtHnNvLCdXZZ w8iWCuDqzyGpWAE3DLiRHcy+CRMwHopl6+hcBOW304wDMumiR5LXN05IGmqCeUQYOd3v KuzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726233563; x=1726838363; 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=gg/pJfNPr78lVbZX5142nrf+6p/6HmhJkcXZ0Cm+gM4=; b=fKcVfM4+5VR5mM2tnvpAlBjO0CNTJZjyzgn78Mh0SuJQ0sNH58Tenw336x8dv7vYBH 4UonylmqpQsVtU+fnaA9qVrqjUoepNSu14NoxC7w9syWq/1DJnQQnEJFsvRhaTdjm/nv VIcywYWI6onSph8/7F7b6oqx6zSfBYxIfwD4KjYfBy8rrsUgOA7BdbAuzHw4HfiRhzWt DoBcmlZOG3ZGBau9v3F3eVzHFmH5MGRqTVhL5j0R59ZuMlRUU19rDY+/wP/xfT8VzCQR ZREkiEmmgao5UCHxYbIUcQnjwhUKVAONR2lWuFhLhPoxT7+sn8RM16bJdZoJR0uAO6p1 9/eA== X-Forwarded-Encrypted: i=1; AJvYcCWuJkjgSDq4Uv0HNxrMTQqFtpdsfALrXzjGUE+Sl+ZBCCJm17Nk6Kpiu0x29KN8Rau1L0k0r+wIX6dU@vger.kernel.org, AJvYcCXLYDGGpJwFS+iOg6VqLp5+knKymcmcAAwk/VZ5VqYqsl64Ifbw9IpEUPHDENPYTyHt2upbi8UFz6aPZ0Re@vger.kernel.org X-Gm-Message-State: AOJu0YyPR53AXwNrikxleV1aejfeEnxcRv7+RYWMMxP1wtdnj0NjRa1r VdSsctBveMwO97ejju2327ThfGna8/v4QtlaZKk+fCNeandoJzA4 X-Google-Smtp-Source: AGHT+IF+cjLWNh8boLkPYB/eCVfAxD4c2886l660M1ICrcArb9JFPIzj+brQd4wTCs9/QYdDW4NBWQ== X-Received: by 2002:a17:907:e687:b0:a8d:2c3e:7ed3 with SMTP id a640c23a62f3a-a90295a6a66mr604263366b.35.1726233563551; Fri, 13 Sep 2024 06:19:23 -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-a8d25a258a3sm865945666b.89.2024.09.13.06.19.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Sep 2024 06:19:23 -0700 (PDT) From: Javier Carrasco Date: Fri, 13 Sep 2024 15:19:01 +0200 Subject: [PATCH 6/7] 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: <20240913-veml6035-v1-6-0b09c0c90418@gmail.com> References: <20240913-veml6035-v1-0-0b09c0c90418@gmail.com> In-Reply-To: <20240913-veml6035-v1-0-0b09c0c90418@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=1726233553; l=1500; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=c0ILQnyW+ImdjeGc6T+fx6mOz4Ws/4vgy5ONpaMk9/4=; b=6IYpwTsCFf+E/BhF9e8v/iPVGpBPPB7W8gcWpwjOVyGwNfs34nmf7TJ+VhiX+npkS3ph1q1ci jj4F7VF/ahXBgYZ1ugGPDJpJu5l61iQL0xJUchd+1avYEBLTwzdpnmo 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. 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 d5add040d0b3..2945cc1db599 100644 --- a/drivers/iio/light/veml6030.c +++ b/drivers/iio/light/veml6030.c @@ -143,8 +143,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 */ + usleep_range(4000, 4002); + + return 0; } static int veml6030_als_shut_down(struct veml6030_data *data) @@ -766,9 +775,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 Fri Sep 13 13:19:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13803447 Received: from mail-ej1-f45.google.com (mail-ej1-f45.google.com [209.85.218.45]) (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 A9D101DC1A4; Fri, 13 Sep 2024 13:19:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726233568; cv=none; b=b9fh0DrRqcDKXqIz3NnkhfoKzemJ/NdCBVKxBT9P7TSbJ1JLJrS1JXj/tSZ8tOCP4ef/U9YCeCa2KHMVFHrOxqpFA6UdlZ18PxKHZ8FpDYDyJjxx64ug8+3J2ptPqcioc7puAv/LAdJgKOLGlkmzNwV1wsu+S2eZQ8l0aRNIHj4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726233568; c=relaxed/simple; bh=t6mgGp9Vg7sGs79HuOV6idIRLy5hQ/Ir5tJ9nVviFUw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=tFHhkFiwWik7/tN9a5JUnFD4fx6MaOfBZEylc89A/F392QI1F7w9Vdju9jOWqZiYOho/xunHbTyu05Dn/1C0cQukb0T0McTxkngj5j3lEbiFH839fCHygtirV1ulV8KKH78MY6KtQ+yq8UVEul+vXHK0dybS/QPX8RbwY9Bcelk= 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=h3wXmPZE; arc=none smtp.client-ip=209.85.218.45 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="h3wXmPZE" Received: by mail-ej1-f45.google.com with SMTP id a640c23a62f3a-a8d4093722bso285531766b.0; Fri, 13 Sep 2024 06:19:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726233565; x=1726838365; 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=e3VOjACAwwRG2xUv/ZVo50qMovzLbtOXrSIBAXe2PmQ=; b=h3wXmPZEiX+L4aDDAlvHFPisgKUSy5AJ1VNgniBF//7QsiPejeqjryhFowpiQ2AIso MS0AAkIqh/S2hROiGSZ3s+QVWEIuFuOAkd5S3LVY1vlAvMRMqGEEt/efAOpFqgu/6uSY 4nkjDXNq0raxk3bDhK9GgGbJB2+ELxwPWSTsE17cQ4WI8WwANpP94tDgDjRRzcr7eOgu ZDOwLK+zQtxnvaa+nNbYcV/wCwtcQ0D0lLWbu3+BrsK48HS7rTI6sMeGuUktNK2WxCaI 7F6Vkt46rfPcBwHPSRVtCf7nruCBq8cqx1VtZJV+9Pm7AEXzR1THPIzkkzDCiA7BJebt udSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726233565; x=1726838365; 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=e3VOjACAwwRG2xUv/ZVo50qMovzLbtOXrSIBAXe2PmQ=; b=kg7yTcgu82Y/7bJRi2JC0BDATXXTpUo8ZIdPCx7Irna0gnNgHN4iSGO5FD0Rqt9g7Q E0Wa28N08zRGPwOuSSkFX5NrPj+CYcat64cOpOUBrbkMBWGCLI/WrxT10CJqwTfc7jsi m4Z2mSDXX2hZ6wIv6rAw+j1wY8qqtJv2i640CCm+PMbP/lSpd7oXxJM40PIA/3jVBSqx fC0bJ1UfxN7KZ6WzMeKQ4m+wvjjIyfGKWhqCDTP2p+X8TS+Bet3ikkK6sRdhrfVk6+Iv xbeyeuAwcew5EX/qXIKaCGi4at00rBwv+Ju9vpPP4ONMHGFgIj4KWlgnzs1Q2XNiogWw 7YXg== X-Forwarded-Encrypted: i=1; AJvYcCUEy59vW/1nkJY9cjytiH0eYCjvrERQdtNfMxeob0Lpem0WeLSkLNX7ZTjk/hC6paQbxxjNTRKgwQglrozj@vger.kernel.org, AJvYcCVMtuPZVCDo09vULr6ec38uSa+kaUEht0silS7GIhEJi9T6bV2fq4KTmfUzvcUoqhyCjnJadk4Lxpmh@vger.kernel.org X-Gm-Message-State: AOJu0YxTUq7Deg1vHruGVtgO3gdcXosiUAoi/T8j7YIc7eQgX7lS+9Qj MQBxsW+kFYmL/TvZq9qkfI7W18+kVn8WCoggk6bVMHOyPfGwV+Nt X-Google-Smtp-Source: AGHT+IEyVGWNoj5HraKCjAhv01hnN28xv9kutpbklD2oY34ELG8GIG/PO0HZ21fKkbGco56j6AnzMg== X-Received: by 2002:a17:907:efc6:b0:a86:9c71:ec93 with SMTP id a640c23a62f3a-a9029438edemr672926866b.24.1726233564939; Fri, 13 Sep 2024 06:19:24 -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-a8d25a258a3sm865945666b.89.2024.09.13.06.19.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Sep 2024 06:19:24 -0700 (PDT) From: Javier Carrasco Date: Fri, 13 Sep 2024 15:19:02 +0200 Subject: [PATCH 7/7] 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: <20240913-veml6035-v1-7-0b09c0c90418@gmail.com> References: <20240913-veml6035-v1-0-0b09c0c90418@gmail.com> In-Reply-To: <20240913-veml6035-v1-0-0b09c0c90418@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=1726233553; l=14378; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=t6mgGp9Vg7sGs79HuOV6idIRLy5hQ/Ir5tJ9nVviFUw=; b=Fhe5cwMkT01pIdBkLK8cwUDGuQ6etJjs+tU3zZuGK1AWIGxAGMcdkPgcdPX/gIGrOHqoxwv8p NomkLKkO57DCfsOkSx5cA9OJoJi0BTDUL4vWZVu3EkkZcpE+IdAv4dI 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/veml6030.c | 300 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 273 insertions(+), 27 deletions(-) diff --git a/drivers/iio/light/veml6030.c b/drivers/iio/light/veml6030.c index 2945cc1db599..105f310c4954 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 @@ -38,16 +44,33 @@ #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 struct iio_info *info; + const struct iio_info *info_no_irq; + const char * const in_illuminance_scale_avail; + 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; @@ -55,6 +78,7 @@ struct veml6030_data { int cur_resolution; int cur_gain; int cur_integration_time; + const struct veml603x_chip *chip; }; /* Integration time available in seconds */ @@ -63,14 +87,25 @@ static IIO_CONST_ATTR(in_illuminance_integration_time_available, /* * 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 IIO_CONST_ATTR(in_illuminance_scale_available, +static IIO_CONST_ATTR_NAMED(veml6030_in_illuminance_scale_available, + in_illuminance_scale_available, "0.125 0.25 1.0 2.0"); +static IIO_CONST_ATTR_NAMED(veml6035_in_illuminance_scale_available, + in_illuminance_scale_available, + "0.125 0.25 0.5 1.0 2.0 4.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, + &iio_const_attr_veml6030_in_illuminance_scale_available.dev_attr.attr, + NULL +}; + +static struct attribute *veml6035_attributes[] = { + &iio_const_attr_in_illuminance_integration_time_available.dev_attr.attr, + &iio_const_attr_veml6035_in_illuminance_scale_available.dev_attr.attr, NULL }; @@ -78,6 +113,10 @@ static const struct attribute_group veml6030_attr_group = { .attrs = veml6030_attributes, }; +static const struct attribute_group veml6035_attr_group = { + .attrs = veml6035_attributes, +}; + /* * Persistence = 1/2/4/8 x integration time * Minimum time for which light readings must stay above configured @@ -380,6 +419,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) { @@ -410,19 +464,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, @@ -462,6 +546,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) { @@ -558,7 +688,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; @@ -569,6 +699,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) { @@ -580,7 +712,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; } @@ -691,12 +823,29 @@ 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, + .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 = &veml6035_attr_group, + .event_attrs = &veml6030_event_attr_group, +}; + static const struct iio_info veml6030_info_no_irq = { .read_raw = veml6030_read_raw, .write_raw = veml6030_write_raw, .attrs = &veml6030_attr_group, }; +static const struct iio_info veml6035_info_no_irq = { + .read_raw = veml6030_read_raw, + .write_raw = veml6030_write_raw, + .attrs = &veml6035_attr_group, +}; + static irqreturn_t veml6030_event_handler(int irq, void *private) { int ret, reg, evtdir; @@ -791,6 +940,73 @@ 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) { + dev_err(&client->dev, "can't shutdown als %d\n", ret); + return ret; + } + + ret = regmap_write(data->regmap, VEML6030_REG_ALS_CONF, + VEML6035_SENS | VEML6035_CHAN_EN | VEML6030_ALS_SD); + if (ret) { + dev_err(&client->dev, "can't setup als configs %d\n", ret); + return ret; + } + + 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; + } + + 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; + } + + 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; + } + + ret = veml6030_als_pwr_on(data); + if (ret) { + dev_err(&client->dev, "can't poweron als %d\n", ret); + return ret; + } + + /* 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; + } + + /* 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; @@ -818,7 +1034,11 @@ static int veml6030_probe(struct i2c_client *client) data->client = client; data->regmap = regmap; - 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; @@ -827,18 +1047,18 @@ 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) { dev_err(&client->dev, "irq %d request failed\n", client->irq); return ret; } - 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 = veml6030_hw_init(indio_dev); + ret = data->chip->hw_init(indio_dev); if (ret < 0) return ret; @@ -879,14 +1099,40 @@ 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", + .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", + .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);