From patchwork Fri Jul 5 10:54:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matti Vaittinen X-Patchwork-Id: 13724938 Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com [209.85.167.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 ABD671494D9; Fri, 5 Jul 2024 10:54:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720176861; cv=none; b=CmWzVHJfYhZ6VBIvs+GonYaAlOccIOE7b/1XjWUjWAlUr7u5pIruWSW1BKsRgHYlsyEWC+4dFPYUGrLKsGElmIL/Fy8zkQCdXA/ZCWNYxE+MoLF/2cncxHpF3WcBes8c9qa3y9+LiNNwb/IykbzD7RwhGSMxRbz85hjdG1DtDwg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720176861; c=relaxed/simple; bh=RnVcsFlEYyDPqf3CWLYFuSkjMBEsRhVWOx/GCvQ+OjU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Lz/bWvhYGJR4s2AO0IlUeb9yTmtteHozfQorDt0B1c3yc/2scZ6VAWhUppv9AgK8B4u6X+jaZwj/FLEcWjEe0kFK3r74ZQIYt4shkabpHdNbP6Tbf74Y+ewa3+U5XTN2Kb+nKOTGrCO9S6ztIDXI+ZlsqQDg0LP/M7xdkBp0HMA= 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=bsDGKiFY; arc=none smtp.client-ip=209.85.167.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="bsDGKiFY" Received: by mail-lf1-f41.google.com with SMTP id 2adb3069b0e04-52e97e5a84bso2183922e87.2; Fri, 05 Jul 2024 03:54:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720176858; x=1720781658; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=SMaSOFsBwSxZehEg946gXs11Hd0r2J8Qex03xKjgN7M=; b=bsDGKiFYctleQE5bRGBdUps7LpB+3OrNTGGm9tiSofEcTaEjgAgwRIKtqGjvqsfwr3 ib96xH40DXcyXPnDi+xnDcXVtt1BhhBjzMNS2B/FbExMQ3B4CHlffVOJB6dDHO70z4A7 Ux0ak07u0LQpHnMgSGjFtkSuEHdYggAXKOUyNRaNvG85aXf0Y/SWlvw1SfBdDHdtQdwF aTKBnR8NFugHbiRtAifG6AMXzc2stItQJ8IcmMTHS0Ai5eIvk7OClDXcLn/SKiKLe+lO oq2lIyBr8xx1S6HadqflLxwGRMggoSWm9ei7C4ZKbXC3XZN9v6yN3fLwYnGYS1MmHK3j ZKIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720176858; x=1720781658; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=SMaSOFsBwSxZehEg946gXs11Hd0r2J8Qex03xKjgN7M=; b=evnB7dZlhtHreTjjaWddx/7+jt3nG4tTPLIqPi/MthELKk201tKCVibLf2UibIUWlY a3Garkc078+Knn2hJHMLZ8+lUqraAiB4HaiK4dIs2cqKePG2QO2Ufu1xiytdLS4ybiUO OfwW/ivIrtRVr0b21xTLDVqdBV4cchxC5ibVZW0fLrMsTesPlgpRBzWqv/udkbSSFb+X o5XUEDdd4nhM/C7CDwyALUkXZdizcS2qZNzr3coIU7aMgO03l2go1+uVg3DvhxxyI1Do /mE2ZT6FO6yWei+rfrdYbgMk4dJWKkJw8CDVnWg4zICEJfzGNxN0v0jt1CdqFKLeMqMg cqYg== X-Forwarded-Encrypted: i=1; AJvYcCU1TRym/9Kd4YKYPFz3O3RYn+sK6uzyYFfs3zFqBe4hEfJk8lpA/+dDXPb7yV6kPzbAhJ7U4YFuwVaVicC/o4UA1hYKWpmVPQIctYfJvmL8IuanfRZVFyLkpl1xieXUhPqF04aEQ+mpITYl2aEqs0AC7ykOIV2FpRoS3ZoyUgnDe6NEdA== X-Gm-Message-State: AOJu0YyxIifxd7J2Xv3wQCJ5acOiXsMYHllwqICelCCQbOQ7eZ5ETFwS 1gOiCgym+9a2OJYIaU4Rwwm1GlwzYM1uTBN9V4pqcSXGUrU50vdRNMCV3A== X-Google-Smtp-Source: AGHT+IEWQ40RNZhfV7Eks6cNnGUujSgPKANOXaSIEAXEp04d6CaSWKXWmQBNw88m1RchKCIyR2Fhuw== X-Received: by 2002:ac2:4568:0:b0:52e:710e:e4d2 with SMTP id 2adb3069b0e04-52ea06327b8mr3502163e87.33.1720176857253; Fri, 05 Jul 2024 03:54:17 -0700 (PDT) Received: from fedora ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-52e95588702sm909212e87.250.2024.07.05.03.54.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jul 2024 03:54:16 -0700 (PDT) Date: Fri, 5 Jul 2024 13:54:12 +0300 From: Matti Vaittinen To: Matti Vaittinen , Matti Vaittinen Cc: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matti Vaittinen , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/7] dt-bindings: iio: BU27034 => BU27034ANUC Message-ID: References: Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: The BU27034NUC was cancelled before it entered mass production. It was replaced by a new variant BU27034ANUC (note, added 'A'). The new variant gained a few significant changes, like removal of the 3.rd data channel and dropping some of the gain settings. This means that, from software point of view these ICs are incompatible. Lux calculation based on the data from the sensors needs to be done differently, and on the BU27034ANUC the channel 3 data is missing. Also, the gain setting differencies matter. Unfortunately, the identification register was not changed so there is no safe way for the software to distinguish the variants. According to the ROHM HQ engineers, the old BU27034NUC should not be encountered in the wild. Hence it makes sense to remove the support for the old BU27034NUC and add support for the new BU27034ANUC. Change the compatible in order to not load the incompatible old driver for new sensor (or, if someone had the old sensor, the new driver for it). Drop the compatible for old sensor which should not be in the wild and add a new compatible for the new model with accurate model suffix 'anuc'. Signed-off-by: Matti Vaittinen Acked-by: Conor Dooley --- A patch renaming the file according to the new compatible will follow. If renaming is not needed or appropriate, that patch can be dropped. Revision history: v2: New patch --- .../devicetree/bindings/iio/light/rohm,bu27034.yaml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Documentation/devicetree/bindings/iio/light/rohm,bu27034.yaml b/Documentation/devicetree/bindings/iio/light/rohm,bu27034.yaml index 30a109a1bf3b..535bd18348ac 100644 --- a/Documentation/devicetree/bindings/iio/light/rohm,bu27034.yaml +++ b/Documentation/devicetree/bindings/iio/light/rohm,bu27034.yaml @@ -4,20 +4,19 @@ $id: http://devicetree.org/schemas/iio/light/rohm,bu27034.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# -title: ROHM BU27034 ambient light sensor +title: ROHM BU27034ANUC ambient light sensor maintainers: - Matti Vaittinen description: | - ROHM BU27034 is an ambient light sesnor with 3 channels and 3 photo diodes + ROHM BU27034ANUC is an ambient light sesnor with 2 channels and 2 photo diodes capable of detecting a very wide range of illuminance. Typical application is adjusting LCD and backlight power of TVs and mobile phones. - https://fscdn.rohm.com/en/products/databook/datasheet/ic/sensor/light/bu27034nuc-e.pdf properties: compatible: - const: rohm,bu27034 + const: rohm,bu27034anuc reg: maxItems: 1 @@ -37,7 +36,7 @@ examples: #size-cells = <0>; light-sensor@38 { - compatible = "rohm,bu27034"; + compatible = "rohm,bu27034anuc"; reg = <0x38>; vdd-supply = <&vdd>; }; From patchwork Fri Jul 5 10:54:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matti Vaittinen X-Patchwork-Id: 13724939 Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com [209.85.167.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 205EB149C42; Fri, 5 Jul 2024 10:54:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720176875; cv=none; b=seEXsBd/MnPHYPNkCe/9+KONNjXlHiOCK/PU6C2Gh1e3nmZ3ufqe3QXjGEyOqiTl53SycRP8xXxP5HBErO95zotNKhvATc4NZEuTarp9jMXwwUY38t4QSdJfieV6DWmyc54FbUp4ppJ2u7rxoyf4eCUKFKAVtcFviEKTRHtzz6Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720176875; c=relaxed/simple; bh=tUZZJwqoiFgry5Esh8LOVnwmGazsXJkRNcHTuOKUs2E=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=JfWKTw64VLl43nVC3FBDj5Z0rUESma+9dGYjou7puuyTLd8Wr2Uo+561lKlnPrBGUAIAClUP60V9XosO8B+UODVYhipRbD79PCikO2ODKALoRMVEb9+tYLlJJct4gSI6iPC3OVPKTMxK19Hr5NWFWjrOk0NwuQr1nAmZlp1nbTQ= 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=OLqLq9je; arc=none smtp.client-ip=209.85.167.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="OLqLq9je" Received: by mail-lf1-f48.google.com with SMTP id 2adb3069b0e04-52e9fe05354so2199351e87.1; Fri, 05 Jul 2024 03:54:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720176872; x=1720781672; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=YudsF8797mlyxY0rIdrjntR7Tkfynp2mWG0TkyJfInQ=; b=OLqLq9jek55fAA+THV4sIFCp93vdXiUwRLWSOd0bGFsy7TAlGH0bs6NhhUE46sdGk2 v9ZIaG0zNjwihLzudVh6SXsfbClLfJ6O4BcefWHDQG1UwXQHISBul8YxJr3ukTtj/nxB cikzhpYma1FZjqBEAlZUNEuzfjW9EyHQhWEPiLF0PkrvFDzR6qOKrjdTNhBA4Iun3FWe h/EW0lmMc4ioZqrDvi0eyrLPbOiYbkMv/afJGC2S7cEqQXUjrzO7iABf7w/p99+J7Q/z iujkBR6G4B6W1DJCaR0vEf6M79EIwR+SskXXDeEgkBEhRGnwAaW1Xq4BDTRVPP0HMG0p WDFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720176872; x=1720781672; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=YudsF8797mlyxY0rIdrjntR7Tkfynp2mWG0TkyJfInQ=; b=Cxb/zYpsbYBmFR7rhJsYYP5txdt4URnbmogAjmQqAfEAubNcZtDfs4IGhYR3LI4sBc T79PBGuyIxHXs7y1c7ujyJIIRYDUTHi8o1IiQ/R8V6yUieRdTl6yMwh7jRkFZ0EtqUiC Hupoih2VAPB5sHv937+1duYx/rL0FGowPGZYNjpJ9tO8d9/Zii27JyMo64x2UyWkGWQ2 g0+wSlA8CT9oj6LhAD0ROe7O5SqplVyp7iyzmXv6+v6G6JZdehjQUZO+IWQSXi9M0ERA eExFdaZJBFIo41cdthcYrl2Hwidv+dCJ0f7nzNoLF8WAlkaPpolADA6+9JE15AogGnA6 q+oQ== X-Forwarded-Encrypted: i=1; AJvYcCVFsk4mxW5zVfO4tP+1nnyQZWaBipnNFcYbC7+rP+0kmDhruwoOEULWsLYnyuYWXoiIWXQZHk5S8msn/XDGfcp24MUVVSGkV/iVd5qx3p1dqK78qWxfOsVOKLbfjpZCs3KsylsRXmeIRkQu5M5hnw7WtmjsJSa6EidRIHTPkmQF7CYJiQ== X-Gm-Message-State: AOJu0YxKIOaD3b7u5kAi5Dz7Azqt77YxmRVReyv8fiMYlCjiMCOp6fIN WItqgpDcmBAN8HTvSHtIHRAUDSuepWzymj9LvHJracwzAb4w9eS0 X-Google-Smtp-Source: AGHT+IFlfAgJaF4n7y57yfhMcwdEk5STkTRSh6C1LpCiPYzBQfbV1MnrgINsP5aLjcI5rsAGqEghPA== X-Received: by 2002:a05:6512:52a:b0:52c:d6a1:5734 with SMTP id 2adb3069b0e04-52ea0619f2amr2945354e87.14.1720176871795; Fri, 05 Jul 2024 03:54:31 -0700 (PDT) Received: from fedora ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-52ea4bd571bsm249300e87.39.2024.07.05.03.54.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jul 2024 03:54:30 -0700 (PDT) Date: Fri, 5 Jul 2024 13:54:26 +0300 From: Matti Vaittinen To: Matti Vaittinen , Matti Vaittinen Cc: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matti Vaittinen , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/7] dt-bindings: iio: rename bu27034 file Message-ID: References: Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: The BU27034NUC was cancelled before it entered mass production. It was replaced by a new variant BU27034ANUC (note, added 'A'). The new variant gained a few significant changes, like removal of the 3.rd data channel and dropping some of the gain settings. This means that, from software point of view these ICs are incompatible. Lux calculation based on the data from the sensors needs to be done differently, and on the BU27034ANUC the channel 3 data is missing. Also, the gain setting differencies matter. The old sensor should not be out there so the compatible was dropped and a new compatible was added for the bu27034anuc. Move the yaml file so the file name matches the binding and change the $id. Signed-off-by: Matti Vaittinen --- Revision history: v1 => v2: - New patch --- .../iio/light/{rohm,bu27034.yaml => rohm,bu27034anuc.yaml} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename Documentation/devicetree/bindings/iio/light/{rohm,bu27034.yaml => rohm,bu27034anuc.yaml} (92%) diff --git a/Documentation/devicetree/bindings/iio/light/rohm,bu27034.yaml b/Documentation/devicetree/bindings/iio/light/rohm,bu27034anuc.yaml similarity index 92% rename from Documentation/devicetree/bindings/iio/light/rohm,bu27034.yaml rename to Documentation/devicetree/bindings/iio/light/rohm,bu27034anuc.yaml index 535bd18348ac..fc3d826ed8ba 100644 --- a/Documentation/devicetree/bindings/iio/light/rohm,bu27034.yaml +++ b/Documentation/devicetree/bindings/iio/light/rohm,bu27034anuc.yaml @@ -1,7 +1,7 @@ # SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) %YAML 1.2 --- -$id: http://devicetree.org/schemas/iio/light/rohm,bu27034.yaml# +$id: http://devicetree.org/schemas/iio/light/rohm,bu27034anuc.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# title: ROHM BU27034ANUC ambient light sensor From patchwork Fri Jul 5 10:54:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matti Vaittinen X-Patchwork-Id: 13724940 Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) (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 8CDF1148FEE; Fri, 5 Jul 2024 10:54:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720176896; cv=none; b=TNoofjCmkjbDRcuZt/0aBG2YPspKRXp7m4VE7a4OtmUV/fqk7I0Wkrps0GKAfKJvcEPGONDU6c6/pheBDhEM4dHEBkzd3+4fwcxUoiAwnzrB68y7Ir6VYMqoZydcDwAo2moJqjWJ4563szMcoSs0VRcXRqp+JFl7SXpIXlLDvgA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720176896; c=relaxed/simple; bh=B6zA9xaRR+yus+M/2QT3KHrJr2/GrdzB64cxur5Apes=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=CRUajdJ+b77zlZ+J5UQKB0lbwhHGJEQIXDlcSC5PMtmq9HN6qZzJnLmDn9aXdt+Om7PswHVtzSHsKjgOWMznI56VgOK0LnP1tbCyKdiQm76JTICd5QW0M2SYN6MjV84MPbj6b0M4wc6bjlEn/JOVmes34CX5eGqjJsRBGY1z8Uk= 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=WBYUILDz; arc=none smtp.client-ip=209.85.167.49 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="WBYUILDz" Received: by mail-lf1-f49.google.com with SMTP id 2adb3069b0e04-52e829086f3so1616331e87.3; Fri, 05 Jul 2024 03:54:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720176893; x=1720781693; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=liXtfBQ59HSNcmRKVJya0/oz8H1ltZnF6eEI6Ipav1Y=; b=WBYUILDzTmtnz//E7w5iO0V8T2pza5GU6wEjMxlFywVE4M4OcOI1A096qRmOFmzb4z Fw1FkULihIPQxPQDaqEZP5yMdVE0+iwNflZQgHDhvffjqAvEWo2hIT6qsj08FFdZvnz7 V5xaYCXIxhzmDTrvGXdRJmWRgmNWLtJEkBlV2c/q7R0cfVBpCDg/KSHZaId+4sHMvtuF WYDZ007QEAPDBQo9LEduXR6f7Tbp/SYT0MyR26Wulfe31xT/OvsLB/vN3EthvRAf20fC dNdLHbme5mECZRZPj7RBaRAc0d+M+wTMVV3iyTf8ssTSOt5NpiKsGFNPLX4105vb7IcH /kjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720176893; x=1720781693; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=liXtfBQ59HSNcmRKVJya0/oz8H1ltZnF6eEI6Ipav1Y=; b=cT3mqEU6HuNlahz/Gdq0T9cyYEGjFJSRg0mPP0Q4dQ3zgrQ17wl/6jysTxU8KSATOO wLK1VPjtYWBw3vCGThWTDuSsefFujcOCLJ0Qrig/GtLX6ZSSeShIyk7WVXMpSaXtoOHU 1Pq2gyX+CNIoWHgLwIt5HLdxnLtDVo8fzv+ZKNDx3j6GfHgPhdfZTySF/Yys4nxCQWJ7 czUtuavhaWvRRNuS2nS95ZgZkbKsYoa/4QFlJahpQ6UvQOkunaCmd5bdGXpbRceKE1YL TbWqldM6XXafFWpO7OIgeLOrJ/0Cj1K2W7n6YivnjpFafWl8e7siTRmCY/aaf0cPfzue yXxQ== X-Forwarded-Encrypted: i=1; AJvYcCVbEAxoEipBDebidGXP4U1mSsNe8a9/kSQTrOC/zJOmDxrBpiMRdyd0QstPvio9ldOPx/sYNJnIJLagrY9hPzXAwKGP3Mfv3Qox1RM7g8Mh6LH2lEH7JQilBd4ltkVf3AuNU639E5ONwI4RXa4e+o2MCT+VCOKqtxmVUKUdyAsQNNHNwA== X-Gm-Message-State: AOJu0YzIuXgMMCouK9s8Ofzwzz2cTxZ07re2hOGDTwrOK422KuzBJBgz 6pJPZP1zPRQKQdxs6E+E5FrrYkLXUD8p5b7ABCrTe0922eTMaKN3zhDz3g== X-Google-Smtp-Source: AGHT+IHRv4oZcpCirCT7C8Be0J+Fy9n8wVOWTYNFmxXs1v9j7H3rtDO1QE8OeI7NfPl0pDC05bRs/Q== X-Received: by 2002:a19:9106:0:b0:52c:8024:1db with SMTP id 2adb3069b0e04-52ea06d307fmr2789397e87.63.1720176892473; Fri, 05 Jul 2024 03:54:52 -0700 (PDT) Received: from fedora ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-52e9ff9f201sm494834e87.27.2024.07.05.03.54.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jul 2024 03:54:51 -0700 (PDT) Date: Fri, 5 Jul 2024 13:54:47 +0300 From: Matti Vaittinen To: Matti Vaittinen , Matti Vaittinen Cc: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matti Vaittinen , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 3/7] bu27034: ROHM BU27034NUC to BU27034ANUC Message-ID: References: Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: The ROHM BU27034NUC was cancelled and BU27034ANUC is replacing this sensor. These senors aren't compatible from the software point of view. According to ROHM, the BU27034NUC was never mass-produced. Hence dropping the BU27034NUC support and using this driver to support BU27034ANUC should not be a problem to users. We however need to ensure than people who use old kernel with the old BU27034NUC driver don't get the old driver probed for the new sensor. Prepare to use the BU27034NUC driver to support the new BU27034ANUC and change the compatible to prevent probing the old driver with the new sensor. Signed-off-by: Matti Vaittinen --- drivers/iio/light/rohm-bu27034.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/iio/light/rohm-bu27034.c b/drivers/iio/light/rohm-bu27034.c index bf3de853a811..f876bb21ffa5 100644 --- a/drivers/iio/light/rohm-bu27034.c +++ b/drivers/iio/light/rohm-bu27034.c @@ -1,9 +1,8 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * BU27034 ROHM Ambient Light Sensor + * BU27034ANUC ROHM Ambient Light Sensor * * Copyright (c) 2023, ROHM Semiconductor. - * https://fscdn.rohm.com/en/products/databook/datasheet/ic/sensor/light/bu27034nuc-e.pdf */ #include @@ -1507,7 +1506,7 @@ static int bu27034_probe(struct i2c_client *i2c) } static const struct of_device_id bu27034_of_match[] = { - { .compatible = "rohm,bu27034" }, + { .compatible = "rohm,bu27034anuc" }, { } }; MODULE_DEVICE_TABLE(of, bu27034_of_match); From patchwork Fri Jul 5 10:55:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matti Vaittinen X-Patchwork-Id: 13724941 Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) (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 65D3114A097; Fri, 5 Jul 2024 10:55:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720176913; cv=none; b=AE9oC1NNOiMQvkwRbCFBDfd/Zsvfxb7WuI09OuJ0DNNDv0Thw5HFOOd4mU9F8nEl8pokO4j17YuqMdmjI6iYv06p5qT2PRCsVIcctarvFJAP3c/agy2hJz4/DLu8j1mB4nflobVwnVSJKa1q18jE3Xt4eNYloN9FhVToyApmO5Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720176913; c=relaxed/simple; bh=HI+sQcyToYP3AHzvRgs7ALxEDV5Q8tjimOtKlODEuLU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=HoFQMCbdoIvXRageGywBk4XaxrMjhciAWRT+/loS1TWk4e1QraIHyio7kgw69aCvmXD6aJApNtlid8VE9AJ5zmyfYiaNrrlnpOIbL0XPDLIOIKHPakjm/Tnmk6U7HBZdoCkllj3yI+we2iFiazdqawSf5Pl6PwylwuaSLzpi3bw= 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=kSzMYHPT; arc=none smtp.client-ip=209.85.208.175 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="kSzMYHPT" Received: by mail-lj1-f175.google.com with SMTP id 38308e7fff4ca-2ee98947f70so1232281fa.1; Fri, 05 Jul 2024 03:55:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720176910; x=1720781710; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=9fwtvcdlweMGd2QiElI8TeM324PEzcDKDnI9f687yxY=; b=kSzMYHPTToyllg64Ffq+fPFnKzqvDTXMVw1EiFfo+VWQV6Pai70w1n0YGEF/DeHm9J YccFd0jb5I4OdklksWw4pA1Z2mEAua5QPmHGomMoUPBF8iVOlyY4CcEvPH80rWTsRVfq bGWjG12lcWVx/eMARmqEezZ6ddji7GOv1d/e9Cx9NQLNpIdJLCU58tXJToDJcvrfsDiB kiAy/A5uD29AUTMa1j8ept1fkCoJJ017b7uzPHEPiLT4tWEaDtbEef3R4tLbhk4J8iEq C64qQufEM7XVC4MS3qqBEfAO5UYxlfmig+mTnIh2KrJV+YYyWZ1ga/A+haAWBJj/bxjk eVFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720176910; x=1720781710; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=9fwtvcdlweMGd2QiElI8TeM324PEzcDKDnI9f687yxY=; b=RlV+WhuVXF5lxL1irtVnZMQnqhZLX1Fht35dJBUViNT1c5p9Z5GGpdHmUkExcfk2Qz m8WvAtB0zunLUECqoDx+c25JCfGNjCFkJIajb1ZdE6T62kvT6mawLqYVo0/hhDQFBCmf +pVBDhX7If6sqc+own1C7oJnHY8pxqxpVgdlBiVknHY2+6jqA2knvNagKoRGlz9RrVkB VnglKJsQQilC/jijn+wgxR0rQXJ4SIxWfk/pB6i1oPWPQ072NXl80uqo0oZg1gpDr4rJ t3Qa0WAuzYkyhEXqsPRmjDx8iDxt6n4QPGvGA8l8syTZKpCLNfxXjhE00Tvc6f6ut442 iTpQ== X-Forwarded-Encrypted: i=1; AJvYcCVJJubnPnOMbQnvApM9dgn8PoKMrtbJQF/zRmnE4CsQeUQHhe4IvesFr+2mw992vj3X3nSqVcryjR1T3yPAUEASUxW7LMT/lKApOVJSzExy4uaXhgVYqmAe/4Hvhx2BoRJQ2Gwv0z3YkZIXXkvc2zh3KyqemfZFGF+nvYTx98v39K6F0g== X-Gm-Message-State: AOJu0YwPpYLvV8WKeDgUmVILw2Imdxlj0i6sw6XBxDlCc5yyPN9hhYPH jtlKFaPt6A3kiOBllSm5ycBFIHUOuyiSocFfd9W4+DqHcUm2Rn/h X-Google-Smtp-Source: AGHT+IFmQqi9ZfmaKxDU4qnmIDKXCPS7LX8lggs+yNIXNA/gNYpjq+MLZy2rIK9L4yoAycfGv1JT4Q== X-Received: by 2002:a2e:300e:0:b0:2ee:8b5d:715f with SMTP id 38308e7fff4ca-2ee8ee13ef6mr22227331fa.45.1720176908881; Fri, 05 Jul 2024 03:55:08 -0700 (PDT) Received: from fedora ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2ee516803c4sm26618861fa.93.2024.07.05.03.55.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jul 2024 03:55:08 -0700 (PDT) Date: Fri, 5 Jul 2024 13:55:03 +0300 From: Matti Vaittinen To: Matti Vaittinen , Matti Vaittinen Cc: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matti Vaittinen , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 4/7] bu27034: ROHM BU27034NUC to BU27034ANUC drop data2 Message-ID: <6f261d4499e9c0e161279717261cc9a20764a6bd.1720176341.git.mazziesaccount@gmail.com> References: Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: The ROHM BU27034NUC was cancelled and BU27034ANUC is replacing this sensor. The BU27034ANUC does not have the data2 channel. Drop the data2 channel. Signed-off-by: Matti Vaittinen --- Revision history: v1 => v2: - patch splitted - fixed empty lines in bu27034_get_gain_sel() --- drivers/iio/light/rohm-bu27034.c | 138 +++++++------------------------ 1 file changed, 28 insertions(+), 110 deletions(-) diff --git a/drivers/iio/light/rohm-bu27034.c b/drivers/iio/light/rohm-bu27034.c index f876bb21ffa5..86b8771caff0 100644 --- a/drivers/iio/light/rohm-bu27034.c +++ b/drivers/iio/light/rohm-bu27034.c @@ -29,17 +29,15 @@ #define BU27034_REG_MODE_CONTROL2 0x42 #define BU27034_MASK_D01_GAIN GENMASK(7, 3) -#define BU27034_MASK_D2_GAIN_HI GENMASK(7, 6) -#define BU27034_MASK_D2_GAIN_LO GENMASK(2, 0) #define BU27034_REG_MODE_CONTROL3 0x43 #define BU27034_REG_MODE_CONTROL4 0x44 #define BU27034_MASK_MEAS_EN BIT(0) #define BU27034_MASK_VALID BIT(7) +#define BU27034_NUM_HW_DATA_CHANS 2 #define BU27034_REG_DATA0_LO 0x50 #define BU27034_REG_DATA1_LO 0x52 -#define BU27034_REG_DATA2_LO 0x54 -#define BU27034_REG_DATA2_HI 0x55 +#define BU27034_REG_DATA1_HI 0x53 #define BU27034_REG_MANUFACTURER_ID 0x92 #define BU27034_REG_MAX BU27034_REG_MANUFACTURER_ID @@ -87,12 +85,12 @@ enum { BU27034_CHAN_ALS, BU27034_CHAN_DATA0, BU27034_CHAN_DATA1, - BU27034_CHAN_DATA2, BU27034_NUM_CHANS }; static const unsigned long bu27034_scan_masks[] = { - GENMASK(BU27034_CHAN_DATA2, BU27034_CHAN_ALS), 0 + GENMASK(BU27034_CHAN_DATA1, BU27034_CHAN_DATA0), + GENMASK(BU27034_CHAN_DATA1, BU27034_CHAN_ALS), 0 }; /* @@ -155,11 +153,10 @@ static const struct iio_itime_sel_mul bu27034_itimes[] = { GAIN_SCALE_ITIME_US(55000, BU27034_MEAS_MODE_55MS, 1), }; -#define BU27034_CHAN_DATA(_name, _ch2) \ +#define BU27034_CHAN_DATA(_name) \ { \ .type = IIO_INTENSITY, \ .channel = BU27034_CHAN_##_name, \ - .channel2 = (_ch2), \ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \ BIT(IIO_CHAN_INFO_SCALE), \ .info_mask_separate_available = BIT(IIO_CHAN_INFO_SCALE), \ @@ -194,13 +191,12 @@ static const struct iio_chan_spec bu27034_channels[] = { /* * The BU27034 DATA0 and DATA1 channels are both on the visible light * area (mostly). The data0 sensitivity peaks at 500nm, DATA1 at 600nm. - * These wave lengths are pretty much on the border of colours making - * these a poor candidates for R/G/B standardization. Hence they're both - * marked as clear channels + * These wave lengths are cyan(ish) and orange(ish), making these + * sub-optiomal candidates for R/G/B standardization. Hence the + * colour modifier is omitted. */ - BU27034_CHAN_DATA(DATA0, IIO_MOD_LIGHT_CLEAR), - BU27034_CHAN_DATA(DATA1, IIO_MOD_LIGHT_CLEAR), - BU27034_CHAN_DATA(DATA2, IIO_MOD_LIGHT_IR), + BU27034_CHAN_DATA(DATA0), + BU27034_CHAN_DATA(DATA1), IIO_CHAN_SOFT_TIMESTAMP(4), }; @@ -214,20 +210,14 @@ struct bu27034_data { struct mutex mutex; struct iio_gts gts; struct task_struct *task; - __le16 raw[3]; + __le16 raw[BU27034_NUM_HW_DATA_CHANS]; struct { u32 mlux; - __le16 channels[3]; + __le16 channels[BU27034_NUM_HW_DATA_CHANS]; s64 ts __aligned(8); } scan; }; -struct bu27034_result { - u16 ch0; - u16 ch1; - u16 ch2; -}; - static const struct regmap_range bu27034_volatile_ranges[] = { { .range_min = BU27034_REG_SYSTEM_CONTROL, @@ -237,7 +227,7 @@ static const struct regmap_range bu27034_volatile_ranges[] = { .range_max = BU27034_REG_MODE_CONTROL4, }, { .range_min = BU27034_REG_DATA0_LO, - .range_max = BU27034_REG_DATA2_HI, + .range_max = BU27034_REG_DATA1_HI, }, }; @@ -249,7 +239,7 @@ static const struct regmap_access_table bu27034_volatile_regs = { static const struct regmap_range bu27034_read_only_ranges[] = { { .range_min = BU27034_REG_DATA0_LO, - .range_max = BU27034_REG_DATA2_HI, + .range_max = BU27034_REG_DATA1_HI, }, { .range_min = BU27034_REG_MANUFACTURER_ID, .range_max = BU27034_REG_MANUFACTURER_ID, @@ -278,41 +268,17 @@ struct bu27034_gain_check { static int bu27034_get_gain_sel(struct bu27034_data *data, int chan) { + int reg[] = { + [BU27034_CHAN_DATA0] = BU27034_REG_MODE_CONTROL2, + [BU27034_CHAN_DATA1] = BU27034_REG_MODE_CONTROL3, + }; int ret, val; - switch (chan) { - case BU27034_CHAN_DATA0: - case BU27034_CHAN_DATA1: - { - int reg[] = { - [BU27034_CHAN_DATA0] = BU27034_REG_MODE_CONTROL2, - [BU27034_CHAN_DATA1] = BU27034_REG_MODE_CONTROL3, - }; - ret = regmap_read(data->regmap, reg[chan], &val); - if (ret) - return ret; - - return FIELD_GET(BU27034_MASK_D01_GAIN, val); - } - case BU27034_CHAN_DATA2: - { - int d2_lo_bits = fls(BU27034_MASK_D2_GAIN_LO); - - ret = regmap_read(data->regmap, BU27034_REG_MODE_CONTROL2, &val); - if (ret) - return ret; + ret = regmap_read(data->regmap, reg[chan], &val); + if (ret) + return ret; - /* - * The data2 channel gain is composed by 5 non continuous bits - * [7:6], [2:0]. Thus when we combine the 5-bit 'selector' - * from register value we must right shift the high bits by 3. - */ - return FIELD_GET(BU27034_MASK_D2_GAIN_HI, val) << d2_lo_bits | - FIELD_GET(BU27034_MASK_D2_GAIN_LO, val); - } - default: - return -EINVAL; - } + return FIELD_GET(BU27034_MASK_D01_GAIN, val); } static int bu27034_get_gain(struct bu27034_data *data, int chan, int *gain) @@ -395,44 +361,9 @@ static int bu27034_write_gain_sel(struct bu27034_data *data, int chan, int sel) }; int mask, val; - if (chan != BU27034_CHAN_DATA0 && chan != BU27034_CHAN_DATA1) - return -EINVAL; - val = FIELD_PREP(BU27034_MASK_D01_GAIN, sel); - mask = BU27034_MASK_D01_GAIN; - if (chan == BU27034_CHAN_DATA0) { - /* - * We keep the same gain for channel 2 as we set for channel 0 - * We can't allow them to be individually controlled because - * setting one will impact also the other. Also, if we don't - * always update both gains we may result unsupported bit - * combinations. - * - * This is not nice but this is yet another place where the - * user space must be prepared to surprizes. Namely, see chan 2 - * gain changed when chan 0 gain is changed. - * - * This is not fatal for most users though. I don't expect the - * channel 2 to be used in any generic cases - the intensity - * values provided by the sensor for IR area are not openly - * documented. Also, channel 2 is not used for visible light. - * - * So, if there is application which is written to utilize the - * channel 2 - then it is probably specifically targeted to this - * sensor and knows how to utilize those values. It is safe to - * hope such user can also cope with the gain changes. - */ - mask |= BU27034_MASK_D2_GAIN_LO; - - /* - * The D2 gain bits are directly the lowest bits of selector. - * Just do add those bits to the value - */ - val |= sel & BU27034_MASK_D2_GAIN_LO; - } - return regmap_update_bits(data->regmap, reg[chan], mask, val); } @@ -440,13 +371,6 @@ static int bu27034_set_gain(struct bu27034_data *data, int chan, int gain) { int ret; - /* - * We don't allow setting channel 2 gain as it messes up the - * gain for channel 0 - which shares the high bits - */ - if (chan != BU27034_CHAN_DATA0 && chan != BU27034_CHAN_DATA1) - return -EINVAL; - ret = iio_gts_find_sel_by_gain(&data->gts, gain); if (ret < 0) return ret; @@ -570,9 +494,6 @@ static int bu27034_set_scale(struct bu27034_data *data, int chan, int ret, time_sel, gain_sel, i; bool found = false; - if (chan == BU27034_CHAN_DATA2) - return -EINVAL; - if (chan == BU27034_CHAN_ALS) { if (val == 0 && val2 == 1000000) return 0; @@ -597,9 +518,7 @@ static int bu27034_set_scale(struct bu27034_data *data, int chan, /* * Populate information for the other channel which should also - * maintain the scale. (Due to the HW limitations the chan2 - * gets the same gain as chan0, so we only need to explicitly - * set the chan 0 and 1). + * maintain the scale. */ if (chan == BU27034_CHAN_DATA0) gain.chan = BU27034_CHAN_DATA1; @@ -613,7 +532,7 @@ static int bu27034_set_scale(struct bu27034_data *data, int chan, /* * Iterate through all the times to see if we find one which * can support requested scale for requested channel, while - * maintaining the scale for other channels + * maintaining the scale for the other channel */ for (i = 0; i < data->gts.num_itime; i++) { new_time_sel = data->gts.itime_table[i].sel; @@ -628,7 +547,7 @@ static int bu27034_set_scale(struct bu27034_data *data, int chan, if (ret) continue; - /* Can the other channel(s) maintain scale? */ + /* Can the other channel maintain scale? */ ret = iio_gts_find_new_gain_sel_by_old_gain_time( &data->gts, gain.old_gain, time_sel, new_time_sel, &gain.new_gain); @@ -640,7 +559,7 @@ static int bu27034_set_scale(struct bu27034_data *data, int chan, } if (!found) { dev_dbg(data->dev, - "Can't set scale maintaining other channels\n"); + "Can't set scale maintaining other channel\n"); ret = -EINVAL; goto unlock_out; @@ -972,7 +891,6 @@ static int bu27034_read_result(struct bu27034_data *data, int chan, int *res) int reg[] = { [BU27034_CHAN_DATA0] = BU27034_REG_DATA0_LO, [BU27034_CHAN_DATA1] = BU27034_REG_DATA1_LO, - [BU27034_CHAN_DATA2] = BU27034_REG_DATA2_LO, }; int valid, ret; __le16 val; @@ -1039,7 +957,7 @@ static int bu27034_get_single_result(struct bu27034_data *data, int chan, { int ret; - if (chan < BU27034_CHAN_DATA0 || chan > BU27034_CHAN_DATA2) + if (chan < BU27034_CHAN_DATA0 || chan > BU27034_CHAN_DATA1) return -EINVAL; ret = bu27034_meas_set(data, true); @@ -1138,7 +1056,7 @@ static int bu27034_calc_mlux(struct bu27034_data *data, __le16 *res, int *val) static int bu27034_get_mlux(struct bu27034_data *data, int chan, int *val) { - __le16 res[3]; + __le16 res[BU27034_NUM_HW_DATA_CHANS]; int ret; ret = bu27034_meas_set(data, true); From patchwork Fri Jul 5 10:55:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matti Vaittinen X-Patchwork-Id: 13724942 Received: from mail-lj1-f182.google.com (mail-lj1-f182.google.com [209.85.208.182]) (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 00F141494B2; Fri, 5 Jul 2024 10:55:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720176927; cv=none; b=A1jU1STwCNUBrsbJ89XSWRnV7IboyVlJiAKOVfQD0gN7sq/6YlENrSOo6Ryf5R2SZZz1LCtA1+l+p2hGo5fdNk1zLRC0reWx9BnIigFTukftRTDvsHT5tc/zLC+r8eoJ1QIpwKqCJn6DRvb03HNZbxIQB6RqpNVUtNsCGjx1QFQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720176927; c=relaxed/simple; bh=uizZIXQWBHm/nBSdPOwzmlkSiKo+SRxFRLi7vHlsv9s=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=A9C9c9VXIX14T3VrMS5pTfQcQFFHkaQalBhqk6zVRUYDSDukYQaBu2wspNi5uY0YM5knc/NT8JpBhqFa4L4fLDwRisgE/+rrlEJt2CEy4JTnECmApiO7hiUIqMhF5sjqq2gn2Ec+1XZOtNDRfVWrq1y6w1QTNLnvNlfAAMOMq5U= 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=iWOl7N+G; arc=none smtp.client-ip=209.85.208.182 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="iWOl7N+G" Received: by mail-lj1-f182.google.com with SMTP id 38308e7fff4ca-2ee9505cd37so5644961fa.2; Fri, 05 Jul 2024 03:55:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720176924; x=1720781724; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=l38WS20I2ZkeICm8h8eAH34Be7x0pCth3bMK+qjFUAA=; b=iWOl7N+Gg1D92iFphVLz2Yd6AE5qE09wims44PJ2KkQiz9aCLd8jQi2EQP8FnWal+h w0J6azglIHO5PpWBVKpN6pSdmzvfBJE9krQP2vTSnyu+QrmCUCo6MM/u1vthn7qee5nJ VCCO72pVLRangZgLrjld2nCCOcOYyz/ue1tdhjMNhqvFdaNjYc8Xs+VV2BGfgtYGBaGI KQLnEVp6cRdl+tvpU7MxOgi9hbqjd6gPNCWXITn/xQquAaEaSjRCGZwFuy1aqsYaMj3n gU/CdNqDWbvh0pQBakEvRLA+Zp9WpQUL3/H3ePKFNG2+X1tSqi4c5ln1prTUVY8Cn9BJ IHOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720176924; x=1720781724; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=l38WS20I2ZkeICm8h8eAH34Be7x0pCth3bMK+qjFUAA=; b=PgqMXcXD6wx32DfzFlk0kOxEHE/xaz7bcUOkgvnz7zWE9iPwbZ/ALHzz9txiL+0b62 CgOcQAjccZYty+U+zADrZ7pT0ac/lc4KmH7APR5gzgOEFDcMT1wdPWthoSbskQwdEucS s3gKpdMcBsZnynO6X3E9mDzFu+TO6rGPGDyg9vp27nqxegitiKzEDaIzXnBKnvWcLnWI lmCAYuJVr+4bB4MPo/UT5kB2FjHi8U81GD7u2Tu+ErP7bltm+l8M9tq6Ju6hb1noepKa b5n8uBGAP4OCXiMj5IF4ZR84JN7EtBdzOdVwwasZzbTguGJuJTmvRiOzpHjUVHwIPAOP E0IA== X-Forwarded-Encrypted: i=1; AJvYcCUeiEkgTiWXsZt+Zus9BfrA897ggiqFQQmmLn3BaalQ6Y7kC8nA+SPy/O7eq4zrEg0gX5FvLsdZKwUN67OlxRcSz1etbBK4VMFzXMHWtm+w0m8HhJEnT/vViFaU/9NHHC9Qzp9RWVj2Je43AK5wgCDz/xDsR+vcOBA8+al1GoFeHOwSPQ== X-Gm-Message-State: AOJu0Yx2La+c0hrERne5RA+wSza6H9usHfuY8guCmnFFcL0zbS2xsAC8 nMypzjxng0icz/NrbVzRd92Gug+kjc4iBorcIQlpV77iDwP9IxGN X-Google-Smtp-Source: AGHT+IEqEpKW8Uw8UxN4TC6arB7J/zSXGBUaP3mzr1hB86ne8sxQ75qXNrPzZvEouJ3lvKfuyf/DUQ== X-Received: by 2002:a2e:9515:0:b0:2eb:f472:e7d3 with SMTP id 38308e7fff4ca-2ee8ed22c62mr29336611fa.6.1720176923713; Fri, 05 Jul 2024 03:55:23 -0700 (PDT) Received: from fedora ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2ee516969d3sm26595771fa.132.2024.07.05.03.55.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jul 2024 03:55:22 -0700 (PDT) Date: Fri, 5 Jul 2024 13:55:19 +0300 From: Matti Vaittinen To: Matti Vaittinen , Matti Vaittinen Cc: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matti Vaittinen , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 5/7] bu27034: ROHM BU27034ANUC correct gains and times Message-ID: <19f8cca2b5498fbfea6e657b7b9c90b78516866a.1720176341.git.mazziesaccount@gmail.com> References: Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: The ROHM BU27034NUC was cancelled and BU27034ANUC is replacing this sensor. The BU27034ANUC does not support all the gains or all the integration times that were supported on BU27034NUC. Srop unsupported times and gains Signed-off-by: Matti Vaittinen --- Revision history: v1 => v2: - splitted from a big patch, no real changes --- drivers/iio/light/rohm-bu27034.c | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/drivers/iio/light/rohm-bu27034.c b/drivers/iio/light/rohm-bu27034.c index 86b8771caff0..850ec78f5405 100644 --- a/drivers/iio/light/rohm-bu27034.c +++ b/drivers/iio/light/rohm-bu27034.c @@ -94,49 +94,39 @@ static const unsigned long bu27034_scan_masks[] = { }; /* - * Available scales with gain 1x - 4096x, timings 55, 100, 200, 400 mS + * Available scales with gain 1x - 1024x, timings 55, 100, 200, 400 mS * Time impacts to gain: 1x, 2x, 4x, 8x. * - * => Max total gain is HWGAIN * gain by integration time (8 * 4096) = 32768 + * => Max total gain is HWGAIN * gain by integration time (8 * 1024) = 8192 + * if 1x gain is scale 1, scale for 2x gain is 0.5, 4x => 0.25, + * ... 8192x => 0.0001220703125 => 122070.3125 nanos * - * Using NANO precision for scale we must use scale 64x corresponding gain 1x - * to avoid precision loss. (32x would result scale 976 562.5(nanos). + * Using NANO precision for scale, we must use scale 16x corresponding gain 1x + * to avoid precision loss. (8x would result scale 976 562.5(nanos). */ -#define BU27034_SCALE_1X 64 +#define BU27034_SCALE_1X 16 /* See the data sheet for the "Gain Setting" table */ #define BU27034_GSEL_1X 0x00 /* 00000 */ #define BU27034_GSEL_4X 0x08 /* 01000 */ -#define BU27034_GSEL_16X 0x0a /* 01010 */ #define BU27034_GSEL_32X 0x0b /* 01011 */ -#define BU27034_GSEL_64X 0x0c /* 01100 */ #define BU27034_GSEL_256X 0x18 /* 11000 */ #define BU27034_GSEL_512X 0x19 /* 11001 */ #define BU27034_GSEL_1024X 0x1a /* 11010 */ -#define BU27034_GSEL_2048X 0x1b /* 11011 */ -#define BU27034_GSEL_4096X 0x1c /* 11100 */ /* Available gain settings */ static const struct iio_gain_sel_pair bu27034_gains[] = { GAIN_SCALE_GAIN(1, BU27034_GSEL_1X), GAIN_SCALE_GAIN(4, BU27034_GSEL_4X), - GAIN_SCALE_GAIN(16, BU27034_GSEL_16X), GAIN_SCALE_GAIN(32, BU27034_GSEL_32X), - GAIN_SCALE_GAIN(64, BU27034_GSEL_64X), GAIN_SCALE_GAIN(256, BU27034_GSEL_256X), GAIN_SCALE_GAIN(512, BU27034_GSEL_512X), GAIN_SCALE_GAIN(1024, BU27034_GSEL_1024X), - GAIN_SCALE_GAIN(2048, BU27034_GSEL_2048X), - GAIN_SCALE_GAIN(4096, BU27034_GSEL_4096X), }; /* - * The IC has 5 modes for sampling time. 5 mS mode is exceptional as it limits - * the data collection to data0-channel only and cuts the supported range to - * 10 bit. It is not supported by the driver. - * - * "normal" modes are 55, 100, 200 and 400 mS modes - which do have direct - * multiplying impact to the register values (similar to gain). + * Measurement modes are 55, 100, 200 and 400 mS modes - which do have direct + * multiplying impact to the data register values (similar to gain). * * This means that if meas-mode is changed for example from 400 => 200, * the scale is doubled. Eg, time impact to total gain is x1, x2, x4, x8. From patchwork Fri Jul 5 10:55:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matti Vaittinen X-Patchwork-Id: 13724943 Received: from mail-lj1-f172.google.com (mail-lj1-f172.google.com [209.85.208.172]) (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 5FC60147C9A; Fri, 5 Jul 2024 10:55:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720176943; cv=none; b=AtMJ3Weu8q42dfwR2GbIOwdSnUGv72OHhdO7dqhbZN5J4EbUT/CSq+uf/eQKgcqjYutv7JbCYQaL1+XfyrY1K4aA/ufThV9BZBlf0lVeqpf07RS2j3SNRGfZKDMpoy0YasTnyCZ3F8pgbEwAbNEcTdSDWEgofvUUbqUWwLiAQYA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720176943; c=relaxed/simple; bh=zIjoA6Dq9DwPlrvDfQBJ8BrxD5cxRgcvJ4TuPLJdtls=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=JUoTpSCVIHcIP7q+2n7Xk9O2SjFhC5kGrtUAbRUKddsYlwpJTpiBzsNIGO5EVrirXBxLt7/sUjwbpTFocM/rlmEaWjg+95hhGkGdEpSnYs+6kpbmSIjJ7eXhujkb6B3qTq+5dCnlAoOpHTJglET7imZE6BKmmqZsmejwGQj1Y7c= 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=Tc08TT+z; arc=none smtp.client-ip=209.85.208.172 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="Tc08TT+z" Received: by mail-lj1-f172.google.com with SMTP id 38308e7fff4ca-2ebe40673e8so20021411fa.3; Fri, 05 Jul 2024 03:55:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720176939; x=1720781739; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=zq8sVfWi+SvUMeKR0gIcar/+sIzKUyE5bCb4en+xoo4=; b=Tc08TT+z5pB5uCyvKWcvwLltIBqqo+T89bJJiay7ybotf+MSLu98dDTn6dQbDNHxL8 mKkqNWAislqySYtaxK3FxOADmX6XbvLqdOa+A4wyMJc51bnOVDEXBOr4djbId3+e4HRX qe0hZe2KLqbi+QPRTSMIdYB/X5PCPhE9BsvKlXwRlX855OsiYMnul4QLAFd4N6lVvkg9 CmfVoQfWgHuXlh3kYABHe2YlV5pCA5vjuLpWMEG0bOgymHS6GlFTmVLLlwT5Sqbh7FCV INUUYSYdq53bCNusLw4V4EERcDjvD/wG4LuBgjDfevk8/84ds5CO+gOCzxVr8VLrpk3H LMmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720176939; x=1720781739; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=zq8sVfWi+SvUMeKR0gIcar/+sIzKUyE5bCb4en+xoo4=; b=kpzKyY7gRp+j9f+dbohUcN+9ovXpxYu2aKFe+JWjMsAQ6jvLk05HOok4YB0EJZX2gm WMFXjEAF0L0LaxjnXvoaKrA3d179P9kj2nXhCSx7GZUY7VZml8XsxHM+LX6r3UFfcclA I61/gLobLUlIEbZ4a9hDc9XBHkOQ57PENcpGdxVUFWPCr30MuJsUG5WUFvrL906OtZ0b LtIA7op258y2UaRDJ+4Ei8CZmrXBM2AX5EwKylm8hgJa4q50vzHbs71T0xruCW0VKA1j QnTanQ24/9M2hlHkSi2cTCPTpCC3PDBtL729r7brKAHFvKfsDRCU8i1y5zes/5PL7rCr 7sJg== X-Forwarded-Encrypted: i=1; AJvYcCVvmZGgMXWlL3mVsFCFZOxt1dJ16bGLWNhR4unUtNEcsHTsIsWsFLqgO+VJjza4FOS4z02oDTm1ctbj1YTwXJpQdEvvPin6smKefRzCrlyfh+yekqdINd8wM8qLWURMrowSNlByJpQI+tMFDQ2SH02nol6flddc3ULvulS7FHZcA4/Ssg== X-Gm-Message-State: AOJu0YyUTZkXYjRLBoStGr82GMMzTgrIjn0pg5U7J9gh1+l06g4PvSLO M+k76cN3HnzA3Q3/iSpljPzDM6HAYJEO5P6eVUHkADLCouB92sUJ X-Google-Smtp-Source: AGHT+IH6kUGqhfbH7KJBbnKp6WFjNZw8K6WL02KwwxnFntBG3ti0Bh3q+29Ed+gTqgCqsQaG+nq1Dg== X-Received: by 2002:a2e:8397:0:b0:2ee:4aaf:5f16 with SMTP id 38308e7fff4ca-2ee8ed66da3mr27860831fa.1.1720176939083; Fri, 05 Jul 2024 03:55:39 -0700 (PDT) Received: from fedora ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2ee9410f20bsm2286601fa.114.2024.07.05.03.55.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jul 2024 03:55:38 -0700 (PDT) Date: Fri, 5 Jul 2024 13:55:34 +0300 From: Matti Vaittinen To: Matti Vaittinen , Matti Vaittinen Cc: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matti Vaittinen , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 6/7] bu27034: ROHM BU27034ANUC correct lux calculation Message-ID: References: Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: The ROHM BU27034NUC was cancelled and BU27034ANUC is replacing this sensor. The lux computation based on the data from a BU27034ANUC is different from the computation for the data from an old BU27034NUC. Fix the lux computation. Signed-off-by: Matti Vaittinen --- Revision history: v1 => v2: - splitted from a big patch - fix maths in comments to follow the coding style - fix the D1 / D0 ratio logic when picking the right coefficients for Lux calculation --- drivers/iio/light/rohm-bu27034.c | 157 ++++++------------------------- 1 file changed, 31 insertions(+), 126 deletions(-) diff --git a/drivers/iio/light/rohm-bu27034.c b/drivers/iio/light/rohm-bu27034.c index 850ec78f5405..ec4f9bef83f8 100644 --- a/drivers/iio/light/rohm-bu27034.c +++ b/drivers/iio/light/rohm-bu27034.c @@ -573,102 +573,21 @@ static int bu27034_set_scale(struct bu27034_data *data, int chan, } /* - * for (D1/D0 < 0.87): - * lx = 0.004521097 * D1 - 0.002663996 * D0 + - * 0.00012213 * D1 * D1 / D0 + * for (D1/D0 < 1.5): + * lx = (0.001193 * D0 + (-0.0000747) * D1) * ((D1/D0 – 1.5) * (0.25) + 1) * - * => 115.7400832 * ch1 / gain1 / mt - - * 68.1982976 * ch0 / gain0 / mt + - * 0.00012213 * 25600 * (ch1 / gain1 / mt) * 25600 * - * (ch1 /gain1 / mt) / (25600 * ch0 / gain0 / mt) + * => -0.000745625 * D0 + 0.0002515625 * D1 + -0.000018675 * D1 * D1 / D0 * - * A = 0.00012213 * 25600 * (ch1 /gain1 / mt) * 25600 * - * (ch1 /gain1 / mt) / (25600 * ch0 / gain0 / mt) - * => 0.00012213 * 25600 * (ch1 /gain1 / mt) * - * (ch1 /gain1 / mt) / (ch0 / gain0 / mt) - * => 0.00012213 * 25600 * (ch1 / gain1) * (ch1 /gain1 / mt) / - * (ch0 / gain0) - * => 0.00012213 * 25600 * (ch1 / gain1) * (ch1 /gain1 / mt) * - * gain0 / ch0 - * => 3.126528 * ch1 * ch1 * gain0 / gain1 / gain1 / mt /ch0 + * => (6.44 * ch1 / gain1 + 19.088 * ch0 / gain0 - + * 0.47808 * ch1 * ch1 * gain0 / gain1 / gain1 / ch0) / + * mt * - * lx = (115.7400832 * ch1 / gain1 - 68.1982976 * ch0 / gain0) / - * mt + A - * => (115.7400832 * ch1 / gain1 - 68.1982976 * ch0 / gain0) / - * mt + 3.126528 * ch1 * ch1 * gain0 / gain1 / gain1 / mt / - * ch0 + * Else + * lx = 0.001193 * D0 - 0.0000747 * D1 * - * => (115.7400832 * ch1 / gain1 - 68.1982976 * ch0 / gain0 + - * 3.126528 * ch1 * ch1 * gain0 / gain1 / gain1 / ch0) / - * mt - * - * For (0.87 <= D1/D0 < 1.00) - * lx = (0.001331* D0 + 0.0000354 * D1) * ((D1/D0 – 0.87) * (0.385) + 1) - * => (0.001331 * 256 * 100 * ch0 / gain0 / mt + 0.0000354 * 256 * - * 100 * ch1 / gain1 / mt) * ((D1/D0 - 0.87) * (0.385) + 1) - * => (34.0736 * ch0 / gain0 / mt + 0.90624 * ch1 / gain1 / mt) * - * ((D1/D0 - 0.87) * (0.385) + 1) - * => (34.0736 * ch0 / gain0 / mt + 0.90624 * ch1 / gain1 / mt) * - * (0.385 * D1/D0 - 0.66505) - * => (34.0736 * ch0 / gain0 / mt + 0.90624 * ch1 / gain1 / mt) * - * (0.385 * 256 * 100 * ch1 / gain1 / mt / (256 * 100 * ch0 / gain0 / mt) - 0.66505) - * => (34.0736 * ch0 / gain0 / mt + 0.90624 * ch1 / gain1 / mt) * - * (9856 * ch1 / gain1 / mt / (25600 * ch0 / gain0 / mt) + 0.66505) - * => 13.118336 * ch1 / (gain1 * mt) - * + 22.66064768 * ch0 / (gain0 * mt) - * + 8931.90144 * ch1 * ch1 * gain0 / - * (25600 * ch0 * gain1 * gain1 * mt) - * + 0.602694912 * ch1 / (gain1 * mt) - * - * => [0.3489024 * ch1 * ch1 * gain0 / (ch0 * gain1 * gain1) - * + 22.66064768 * ch0 / gain0 - * + 13.721030912 * ch1 / gain1 - * ] / mt - * - * For (D1/D0 >= 1.00) - * - * lx = (0.001331* D0 + 0.0000354 * D1) * ((D1/D0 – 2.0) * (-0.05) + 1) - * => (0.001331* D0 + 0.0000354 * D1) * (-0.05D1/D0 + 1.1) - * => (0.001331 * 256 * 100 * ch0 / gain0 / mt + 0.0000354 * 256 * - * 100 * ch1 / gain1 / mt) * (-0.05D1/D0 + 1.1) - * => (34.0736 * ch0 / gain0 / mt + 0.90624 * ch1 / gain1 / mt) * - * (-0.05 * 256 * 100 * ch1 / gain1 / mt / (256 * 100 * ch0 / gain0 / mt) + 1.1) - * => (34.0736 * ch0 / gain0 / mt + 0.90624 * ch1 / gain1 / mt) * - * (-1280 * ch1 / (gain1 * mt * 25600 * ch0 / gain0 / mt) + 1.1) - * => (34.0736 * ch0 * -1280 * ch1 * gain0 * mt /( gain0 * mt * gain1 * mt * 25600 * ch0) - * + 34.0736 * 1.1 * ch0 / (gain0 * mt) - * + 0.90624 * ch1 * -1280 * ch1 *gain0 * mt / (gain1 * mt *gain1 * mt * 25600 * ch0) - * + 1.1 * 0.90624 * ch1 / (gain1 * mt) - * => -43614.208 * ch1 / (gain1 * mt * 25600) - * + 37.48096 ch0 / (gain0 * mt) - * - 1159.9872 * ch1 * ch1 * gain0 / (gain1 * gain1 * mt * 25600 * ch0) - * + 0.996864 ch1 / (gain1 * mt) - * => [ - * - 0.045312 * ch1 * ch1 * gain0 / (gain1 * gain1 * ch0) - * - 0.706816 * ch1 / gain1 - * + 37.48096 ch0 /gain0 - * ] * mt - * - * - * So, the first case (D1/D0 < 0.87) can be computed to a form: - * - * lx = (3.126528 * ch1 * ch1 * gain0 / (ch0 * gain1 * gain1) + - * 115.7400832 * ch1 / gain1 + - * -68.1982976 * ch0 / gain0 - * / mt - * - * Second case (0.87 <= D1/D0 < 1.00) goes to form: - * - * => [0.3489024 * ch1 * ch1 * gain0 / (ch0 * gain1 * gain1) + - * 13.721030912 * ch1 / gain1 + - * 22.66064768 * ch0 / gain0 - * ] / mt - * - * Third case (D1/D0 >= 1.00) goes to form: - * => [-0.045312 * ch1 * ch1 * gain0 / (ch0 * gain1 * gain1) + - * -0.706816 * ch1 / gain1 + - * 37.48096 ch0 /(gain0 - * ] / mt + * => (1.91232 * ch1 / gain1 + 30.5408 * ch0 / gain0 + + * [0 * ch1 * ch1 * gain0 / gain1 / gain1 / ch0] ) / + * mt * * This can be unified to format: * lx = [ @@ -678,19 +597,14 @@ static int bu27034_set_scale(struct bu27034_data *data, int chan, * ] / mt * * For case 1: - * A = 3.126528, - * B = 115.7400832 - * C = -68.1982976 + * A = -0.47808, + * B = 6.44, + * C = 19.088 * * For case 2: - * A = 0.3489024 - * B = 13.721030912 - * C = 22.66064768 - * - * For case 3: - * A = -0.045312 - * B = -0.706816 - * C = 37.48096 + * A = 0 + * B = 1.91232 + * C = 30.5408 */ struct bu27034_lx_coeff { @@ -795,21 +709,16 @@ static int bu27034_fixp_calc_lx(unsigned int ch0, unsigned int ch1, { static const struct bu27034_lx_coeff coeff[] = { { - .A = 31265280, /* 3.126528 */ - .B = 1157400832, /*115.7400832 */ - .C = 681982976, /* -68.1982976 */ - .is_neg = {false, false, true}, + .A = 4780800, /* -0.47808 */ + .B = 64400000, /* 6.44 */ + .C = 190880000, /* 19.088 */ + .is_neg = { true, false, false }, }, { - .A = 3489024, /* 0.3489024 */ - .B = 137210309, /* 13.721030912 */ - .C = 226606476, /* 22.66064768 */ + .A = 0, /* 0 */ + .B = 19123200, /* 1.91232 */ + .C = 305408000, /* 30.5408 */ /* All terms positive */ - }, { - .A = 453120, /* -0.045312 */ - .B = 7068160, /* -0.706816 */ - .C = 374809600, /* 37.48096 */ - .is_neg = {true, true, false}, - } + }, }; const struct bu27034_lx_coeff *c = &coeff[coeff_idx]; u64 res = 0, terms[3]; @@ -972,12 +881,10 @@ static int bu27034_get_single_result(struct bu27034_data *data, int chan, * D1 = data1/ch1_gain/meas_time_ms * 25600 * * Then: - * if (D1/D0 < 0.87) - * lx = (0.001331 * D0 + 0.0000354 * D1) * ((D1 / D0 - 0.87) * 3.45 + 1) - * else if (D1/D0 < 1) - * lx = (0.001331 * D0 + 0.0000354 * D1) * ((D1 / D0 - 0.87) * 0.385 + 1) - * else - * lx = (0.001331 * D0 + 0.0000354 * D1) * ((D1 / D0 - 2) * -0.05 + 1) + * If (D1/D0 < 1.5) + * lx = (0.001193 * D0 + (-0.0000747) * D1) * ((D1 / D0 – 1.5) * 0.25 + 1) + * Else + * lx = (0.001193 * D0 + (-0.0000747) * D1) * * We use it here. Users who have for example some colored lens * need to modify the calculation but I hope this gives a starting point for @@ -1028,12 +935,10 @@ static int bu27034_calc_mlux(struct bu27034_data *data, __le16 *res, int *val) d1_d0_ratio_scaled /= ch0 * gain1; } - if (d1_d0_ratio_scaled < 87) + if (d1_d0_ratio_scaled < 150) ret = bu27034_fixp_calc_lx(ch0, ch1, gain0, gain1, meastime, 0); - else if (d1_d0_ratio_scaled < 100) - ret = bu27034_fixp_calc_lx(ch0, ch1, gain0, gain1, meastime, 1); else - ret = bu27034_fixp_calc_lx(ch0, ch1, gain0, gain1, meastime, 2); + ret = bu27034_fixp_calc_lx(ch0, ch1, gain0, gain1, meastime, 1); if (ret < 0) return ret; From patchwork Fri Jul 5 10:55:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matti Vaittinen X-Patchwork-Id: 13724944 Received: from mail-lj1-f174.google.com (mail-lj1-f174.google.com [209.85.208.174]) (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 9A50F148823; Fri, 5 Jul 2024 10:55:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720176958; cv=none; b=o5v72FKXUweSJbQF+Ig7GjOQ6BAU+GX+YTn6zE6DL/TrEyKtt6bSIwXUZuyLKhyw4PmpCDJSP8dfY+UchUbqM6qSfowUovRVVZZt9EKpu1/Ph22aftA33+H8O3BFyME4ZCQOHB9dldss37ute3WNG6PmzZzIsg+yngwdNUV4rb0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720176958; c=relaxed/simple; bh=bI2hjWVgdl/diApvpjFZCaQlbk4hRekxYDSv0DqE3K8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=qWXKHwhiDln/Hl9U1K4oXnbvzXPB4b8Jb7AJJTs3MtEv369hBZJ6OP/+YxX4Ytxu16nU5MzjH/fDxPFK1LPWZWHunO5GJ5d4l1MF5aNQ9IzOg5ePOHAj7PwMk81+cKSRxubOK2ZJtZBhesz+yVOE2WGl+nMcQFjPJoN/3UenWl0= 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=IJJgLAml; arc=none smtp.client-ip=209.85.208.174 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="IJJgLAml" Received: by mail-lj1-f174.google.com with SMTP id 38308e7fff4ca-2ec3f875e68so18353861fa.0; Fri, 05 Jul 2024 03:55:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720176955; x=1720781755; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=AhGmMPt1lObSup2GfRLJaEn/G3ib3X+5BiBDXfkwc6Y=; b=IJJgLAmlnOK+tODSrYY1lDccBN5swiAfRCIId06PpANrIb9fuYGFjsugt40/rqco2p glUPlmH/8bw4MfLoiNZLHiG9ZvpKZ0EzH26fGr7sgtRCdajonMJomrrm+VdC8BMoL5Ms iLTXNV+s6MWJhmv6rzAcSIxZjUYYUG9pNcfqloWwnW3yk6G+tXqMDsbNFExUNbksLVDI LZz2dKfytY/Jq5pnFiJgXetn3TODD6w503FDqP7PcLAeRI9szec1O6oS9PL9QG4UIK7C wkkbKZyngd+pVGwBYJqrfXJmfhe1pqfcers4j8opAWqE2n+roFpR99YQuTaflQBwRvfs s5SA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720176955; x=1720781755; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=AhGmMPt1lObSup2GfRLJaEn/G3ib3X+5BiBDXfkwc6Y=; b=qGnKow8Gb+0M8qnY4NEpvq5MmkoTAY9LHpKrCpE9uqvXqraYLgsVR1nOL9GkMXB78C IhYoe8I90zheDMCZ+jWAiu3+59O1yX0rZqor2GtI7+1CdG/wQn9EsMwCFMNCzfTImDdX qAyCys1t0BjbI5aRId9ydOThoX2U72XUKE6OY9tMqg/E2Kmdi7w7IHn9gqIddkFqrjid aYpeLdUdsij7xH6lUEOl6wRSvm4mss59DcVC/czr2dXI/NAnNVoEMtstOvR9nc5gw5oS MHUKv7cQyYnrNHHc7wZI1w9ArBTPOQROK1bOgsBRQUEbaJQmERSFM7S5OT8iJ+AAUdLW cydA== X-Forwarded-Encrypted: i=1; AJvYcCVwCS8yY6qFkjAN5VjRYnvwet80a1in2SOshaEU99fhEFWwrlG1i0LDiM145Db9Zqlc2FJeEvhOuL6CupjVxE8y1GGtS+JqNrDLAqpDKkmgkE7FLz2SMQsGk593O5ByBKybz1BqReJXaWRXKmfl0FYbKJQPgT1gfH/QY+zBKNU5DnxYgg== X-Gm-Message-State: AOJu0YwrQTB4yay3Q8KyRR1Wdb9OgB7k86RkEXPbsscrv412yrWMXueN 1DeF3xn/5/y3Nog5sqjtE/Ryl50CfrCT/BLzau/oFK+lx51T7zWc X-Google-Smtp-Source: AGHT+IHcU4cGkUjrgtXjRt1PrXQ4b4FmjO1xQSJdylbp2isgPfBuBM0XvqRep2ss7UrEZ0oQwd3XtA== X-Received: by 2002:a05:6512:1096:b0:52e:a60e:3a08 with SMTP id 2adb3069b0e04-52ea60e3bfcmr1323370e87.11.1720176954368; Fri, 05 Jul 2024 03:55:54 -0700 (PDT) Received: from fedora ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-52ea2f3f8c2sm321184e87.171.2024.07.05.03.55.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jul 2024 03:55:53 -0700 (PDT) Date: Fri, 5 Jul 2024 13:55:49 +0300 From: Matti Vaittinen To: Matti Vaittinen , Matti Vaittinen Cc: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matti Vaittinen , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 7/7] iio: bu27034: Add a read only HWARDWAREGAIN Message-ID: References: Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: The ROHM BU27034 light sensor has two data channels for measuring different frequencies of light. The result from these channels is combined into Lux value while the raw channel values are reported via intensity channels. Both of the intensity channels have adjustable gain setting which impacts the scale of the raw channels. Eg, doubling the gain will double the values read from the raw channels, which halves the scale value. The integration time can also be set for the sensor. This does also have an impact to the scale of the intensity channels because increasing the integration time will also increase the values reported via the raw channels. Impact of integration time to the scale and the fact that the scale value does not start from '1', can make it hard for a human reader to compute the gain values based on the scale. Add read-only HARDWAREGAIN to help debugging. Signed-off-by: Matti Vaittinen --- Revision history: v1 => v2: - fix switch case fallthrough warning by adding explicit return --- drivers/iio/light/rohm-bu27034.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/iio/light/rohm-bu27034.c b/drivers/iio/light/rohm-bu27034.c index ec4f9bef83f8..76711c3cdf7c 100644 --- a/drivers/iio/light/rohm-bu27034.c +++ b/drivers/iio/light/rohm-bu27034.c @@ -148,7 +148,8 @@ static const struct iio_itime_sel_mul bu27034_itimes[] = { .type = IIO_INTENSITY, \ .channel = BU27034_CHAN_##_name, \ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \ - BIT(IIO_CHAN_INFO_SCALE), \ + BIT(IIO_CHAN_INFO_SCALE) | \ + BIT(IIO_CHAN_INFO_HARDWAREGAIN), \ .info_mask_separate_available = BIT(IIO_CHAN_INFO_SCALE), \ .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_INT_TIME), \ .info_mask_shared_by_all_available = \ @@ -989,6 +990,13 @@ static int bu27034_read_raw(struct iio_dev *idev, return IIO_VAL_INT_PLUS_MICRO; + case IIO_CHAN_INFO_HARDWAREGAIN: + ret = bu27034_get_gain(data, chan->channel, val); + if (ret) + return ret; + + return IIO_VAL_INT; + case IIO_CHAN_INFO_SCALE: return bu27034_get_scale(data, chan->channel, val, val2); @@ -1033,12 +1041,17 @@ static int bu27034_write_raw_get_fmt(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, long mask) { + struct bu27034_data *data = iio_priv(indio_dev); switch (mask) { case IIO_CHAN_INFO_SCALE: return IIO_VAL_INT_PLUS_NANO; case IIO_CHAN_INFO_INT_TIME: return IIO_VAL_INT_PLUS_MICRO; + case IIO_CHAN_INFO_HARDWAREGAIN: + dev_dbg(data->dev, + "HARDWAREGAIN is read-only, use scale to set\n"); + return -EINVAL; default: return -EINVAL; }