From patchwork Fri Dec 29 09:24:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petre Rodan X-Patchwork-Id: 183877 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp2466007dyb; Fri, 29 Dec 2023 01:26:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IHqRzzl7ARAakRdSi+PxZRc/oFS5KtpI5kv7bOA/VlileqJ3ESYj4WoN4m7VVJFp6izgcTu X-Received: by 2002:a17:902:7293:b0:1d3:fa3f:6688 with SMTP id d19-20020a170902729300b001d3fa3f6688mr5537536pll.61.1703841969926; Fri, 29 Dec 2023 01:26:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703841969; cv=none; d=google.com; s=arc-20160816; b=TnCgnB5le8hcBknvKvhPJfwyVjkzhxDHPcOFrZUOeqWuXL+i+m+1t8bXd7MgCGmWDO x5OTyDwA1NshvCpTQqFSzmGxVYz+attBq1RGcxnzY0BuZx/UqRl27WfuJF7I5iIKgxOZ 49iyX5Z8uE4YtIZW7rgMiZyb7zRF9bAhFrLXAj36z0j/xavSxElG3JZ3roVzGdCmlgd/ /o6TOMKkXihs1VVkuUcdJKK5q+iglco84J6PtNSbFK9eptzm3d5Xe2+oYjMVMVrTdeWs dBk86xtEdTXIpvPuC1G5VN8m9pifzIWHFl171KM+V1OShw2bILHYTv6kv9/HyBdz/fg2 8fnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=xJmL4mfeTsSw5I/HgCrYGtj6GqCfQUaHta2nJumCzgU=; fh=0Db9vCP11oNCfBssZT9wzCG4/unYcrRH7BYzLL5p57I=; b=OtpkEcOzdpCDOqEjsGkReD1xFLcURWb/47bVqr/icTJwz0Yl0zMkqdNUUqFmtpKD6y pyCCrxMn7Vx9El9fxuHeVwG+k3SyaAmBSneHD3xEr6uWic9/3YDCM3xSXh1H8uyitnHd PLEvY3zEC7kYU2/PzeyRJzKRpxrjaze3j6RD37qv7exyl7UWLvItwI/q3xusvj4d/D+1 DMPzEJOZRiYUuAo/RXyH59LWAm56zvNQefYX0yXaIDqUFEmXL/g5NR71NVkjURfGjcFw bkcvNdj6bvDKhXevC2hJQiDuBWgOy6R112zPV/8KUi3iqBAMLi1Ol5NTMBh+Um+QhCoO H2ZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@subdimension.ro header.s=skycaves header.b=WwWQReAp; spf=pass (google.com: domain of linux-kernel+bounces-13026-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13026-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=subdimension.ro Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id m24-20020a170902bb9800b001d454ce72d3si8061190pls.581.2023.12.29.01.26.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Dec 2023 01:26:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-13026-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@subdimension.ro header.s=skycaves header.b=WwWQReAp; spf=pass (google.com: domain of linux-kernel+bounces-13026-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13026-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=subdimension.ro Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id A26CC28169E for ; Fri, 29 Dec 2023 09:26:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BBCFE11C99; Fri, 29 Dec 2023 09:25:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=subdimension.ro header.i=@subdimension.ro header.b="WwWQReAp" X-Original-To: linux-kernel@vger.kernel.org Received: from mail.subdimension.ro (skycaves.subdimension.ro [172.104.132.142]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7C4B410A07; Fri, 29 Dec 2023 09:25:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=subdimension.ro Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=subdimension.ro Received: from localhost.localdomain (unknown [188.24.94.216]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mail.subdimension.ro (Postfix) with ESMTPSA id C256C28B538; Fri, 29 Dec 2023 09:25:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=subdimension.ro; s=skycaves; t=1703841906; bh=2cwVTTHJN5btrCaPMvGl74zHSsIr8blS1pdlyCma1r0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=WwWQReApL2OH68s5zu3HYymzkdnynrIRPRUnjGn7+F7Ad/yNrWEas7yq9KULPST0w /ezr7AAQTNQgPfQ+805TEn5P7s1fQY074qIg09h9wb0SRl+zepGDpzVWo3hnUcsCSa tYY4kiylYB+V7RPqpdoETY3uQumKAAKeW5ywZvrY= From: Petre Rodan To: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Petre Rodan , Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Andy Shevchenko , Krzysztof Kozlowski , Andreas Klinger Subject: [PATCH v3 01/10] dt-bindings: iio: pressure: honeywell,mprls0025pa.yaml improvements Date: Fri, 29 Dec 2023 11:24:29 +0200 Message-ID: <20231229092445.30180-2-petre.rodan@subdimension.ro> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231229092445.30180-1-petre.rodan@subdimension.ro> References: <20231229092445.30180-1-petre.rodan@subdimension.ro> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786607797667305495 X-GMAIL-MSGID: 1786607797667305495 Define enum inside the honeywell,transfer-function property block. Set the correct irq edge in the example block. Based on the datasheet, in table 13 on page 11: "End-of-conversion indicator: This pin is set high when a measurement and calculation have been completed and the data is ready to be clocked out" Add description on End-of-conversion interrupt. Acked-by: Krzysztof Kozlowski Co-developed-by: Andreas Klinger Signed-off-by: Andreas Klinger Signed-off-by: Petre Rodan --- v2 -> v3 no changes .../bindings/iio/pressure/honeywell,mprls0025pa.yaml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) -- 2.41.0 diff --git a/Documentation/devicetree/bindings/iio/pressure/honeywell,mprls0025pa.yaml b/Documentation/devicetree/bindings/iio/pressure/honeywell,mprls0025pa.yaml index d9e903fbfd99..84ced4e5a7da 100644 --- a/Documentation/devicetree/bindings/iio/pressure/honeywell,mprls0025pa.yaml +++ b/Documentation/devicetree/bindings/iio/pressure/honeywell,mprls0025pa.yaml @@ -42,6 +42,10 @@ properties: maxItems: 1 interrupts: + description: + Optional interrupt for indicating End-of-conversion. + If not present, the driver loops for a while until the received status + byte indicates correct measurement. maxItems: 1 reset-gpios: @@ -65,6 +69,7 @@ properties: 1 - A, 10% to 90% of 2^24 (1677722 .. 15099494) 2 - B, 2.5% to 22.5% of 2^24 (419430 .. 3774874) 3 - C, 20% to 80% of 2^24 (3355443 .. 13421773) + enum: [1, 2, 3] $ref: /schemas/types.yaml#/definitions/uint32 vdd-supply: @@ -93,7 +98,7 @@ examples: reg = <0x18>; reset-gpios = <&gpio3 19 GPIO_ACTIVE_HIGH>; interrupt-parent = <&gpio3>; - interrupts = <21 IRQ_TYPE_EDGE_FALLING>; + interrupts = <21 IRQ_TYPE_EDGE_RISING>; honeywell,pmin-pascal = <0>; honeywell,pmax-pascal = <172369>; honeywell,transfer-function = <1>; From patchwork Fri Dec 29 09:24:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petre Rodan X-Patchwork-Id: 183880 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp2466378dyb; Fri, 29 Dec 2023 01:27:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IEV4c6nK63sL4HoRKrULbIdqFWBJ5QA+Jpf9W0jGFwLwl0SotOkyFioUnUVzVJ2KZeV0hpC X-Received: by 2002:a05:6871:8a9:b0:203:a43e:5918 with SMTP id r41-20020a05687108a900b00203a43e5918mr5665547oaq.100.1703842037519; Fri, 29 Dec 2023 01:27:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703842037; cv=none; d=google.com; s=arc-20160816; b=PLv+UIbs8X67tP9Vv97fw0+74RKhYElMzhvnd90XGFPefTW4oeWdnOxSpOp72q/obS HYaxg1X8Tr3qKUH5G1mDKUMLBdWJu2XMFNIFq2QkPoQvZbg5qb13YxhE1aIMChy07LRZ ULFVp232zsBAqeM9RCxMru6y7iyZ9gT8MyGP7HGdGKWMcQvRab58BLo0prdEwqpUT+Mq QZN9fhOoOnwTvJiRst5Alv5ILzytmGzEznOMb68yeHtsXUFg8ssOCnskHqHPUS5TcgjP /2TqnlWngY9lBkocB31utXftWfQ249cgCnKE29oK+Td1AvZqcgshJL4e6NGsETU5tsWC Wy/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=qK+05Pb4fpgMxrwxKvwtLsftC6Com0wd5qF74FjgHmI=; fh=jqBctGHbf9AVU5R58vhGWQ3B4pyO5m4xQP1pFNcmSHk=; b=CEUjCENX/+JX/r5ZALJuu47Kn6Z8UUL4cHTUTPGLWqpXeRKqLU8hnNfqGaojrtfyKu cF57pFfVrmD9hp+k/kGAMBQ3UqgM0kETfGuEOgs6BSB1vTtGLjzzc9UXVcGdKDVJg266 q1uMOP0ljidtSY2veDMT62IlTqY3vuIWifRR1RVTNI+sYtU2vuxXCVNIV5nT6drKAuHS kItDpdaoqJ7ZRUTin+sSsiORHbRm9PkMIf+WhfFyLEZtQv/M4/gdTM/ReO/YN32U9gO2 wPVYrF2IcPv8U0BpSkT4LMDAQd5rvDF3wZbYtEebBckhgye+DOIjgK8hFYaAK2eDBzGP Qaog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@subdimension.ro header.s=skycaves header.b=PgYtUOg5; spf=pass (google.com: domain of linux-kernel+bounces-13027-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13027-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=subdimension.ro Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id x65-20020a636344000000b005ce026ab470si10692134pgb.63.2023.12.29.01.27.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Dec 2023 01:27:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-13027-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@subdimension.ro header.s=skycaves header.b=PgYtUOg5; spf=pass (google.com: domain of linux-kernel+bounces-13027-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13027-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=subdimension.ro Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 35D33B22D8F for ; Fri, 29 Dec 2023 09:26:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DBDF611C9F; Fri, 29 Dec 2023 09:25:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=subdimension.ro header.i=@subdimension.ro header.b="PgYtUOg5" X-Original-To: linux-kernel@vger.kernel.org Received: from mail.subdimension.ro (skycaves.subdimension.ro [172.104.132.142]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7C4DC10A09; Fri, 29 Dec 2023 09:25:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=subdimension.ro Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=subdimension.ro Received: from localhost.localdomain (unknown [188.24.94.216]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mail.subdimension.ro (Postfix) with ESMTPSA id 3571128B539; Fri, 29 Dec 2023 09:25:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=subdimension.ro; s=skycaves; t=1703841906; bh=O3ZaENC2I0WZ5kF5kbvTEUEGtJq+npQOkY5nka7EbXM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=PgYtUOg5C+Mvj5+twwGs4YNSSWEBxK5dR0UGK2dk+882GmzKM6stJBclrJHOiDtPL iOSN0mJEzhyXHEGe/3AFSwv9cD731Sk6D9QnQ6csU2gdCAW8ketSuS5S3ZK17H90bR YqF8V1mzPme0db3ko23YpNl5S3Jeyx3V1s1IK3FY= From: Petre Rodan To: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Petre Rodan , Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Andy Shevchenko , Andreas Klinger Subject: [PATCH v3 02/10] dt-bindings: iio: pressure: honeywell,mprls0025pa.yaml add pressure-triplet Date: Fri, 29 Dec 2023 11:24:30 +0200 Message-ID: <20231229092445.30180-3-petre.rodan@subdimension.ro> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231229092445.30180-1-petre.rodan@subdimension.ro> References: <20231229092445.30180-1-petre.rodan@subdimension.ro> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786607868258055954 X-GMAIL-MSGID: 1786607868258055954 Change order of properties in order for the end user to hopefully ignore pmin-pascal and pmax-pascal which are superseded by pressure-triplet. Add pressure-triplet property which automatically initializes pmin-pascal and pmax-pascal inside the driver. Rework honeywell,pmXX-pascal requirements based on feedback from Jonathan and Conor. Co-developed-by: Andreas Klinger Signed-off-by: Andreas Klinger Signed-off-by: Petre Rodan Reviewed-by: Krzysztof Kozlowski --- v2 -> v3 remove redundant pmin, pmax description line .../iio/pressure/honeywell,mprls0025pa.yaml | 64 +++++++++++++------ 1 file changed, 46 insertions(+), 18 deletions(-) -- 2.41.0 diff --git a/Documentation/devicetree/bindings/iio/pressure/honeywell,mprls0025pa.yaml b/Documentation/devicetree/bindings/iio/pressure/honeywell,mprls0025pa.yaml index 84ced4e5a7da..6643e51c481d 100644 --- a/Documentation/devicetree/bindings/iio/pressure/honeywell,mprls0025pa.yaml +++ b/Documentation/devicetree/bindings/iio/pressure/honeywell,mprls0025pa.yaml @@ -19,14 +19,17 @@ description: | calls them "mpr series". All of them have the identical programming model and differ in the pressure range, unit and transfer function. - To support different models one need to specify the pressure range as well as - the transfer function. Pressure range needs to be converted from its unit to - pascal. + To support different models one need to specify its pressure triplet as well + as the transfer function. + + For custom silicon chips not covered by the Honeywell MPR series datasheet, + the pressure values can be specified manually via honeywell,pmin-pascal and + honeywell,pmax-pascal. + The minimal range value stands for the minimum pressure and the maximum value + also for the maximum pressure with linear relation inside the range. The transfer function defines the ranges of numerical values delivered by the - sensor. The minimal range value stands for the minimum pressure and the - maximum value also for the maximum pressure with linear relation inside the - range. + sensor. Specifications about the devices can be found at: https://prod-edam.honeywell.com/content/dam/honeywell-edam/sps/siot/en-us/ @@ -54,14 +57,6 @@ properties: If not present the device is not reset during the probe. maxItems: 1 - honeywell,pmin-pascal: - description: - Minimum pressure value the sensor can measure in pascal. - - honeywell,pmax-pascal: - description: - Maximum pressure value the sensor can measure in pascal. - honeywell,transfer-function: description: | Transfer function which defines the range of valid values delivered by the @@ -72,17 +67,50 @@ properties: enum: [1, 2, 3] $ref: /schemas/types.yaml#/definitions/uint32 + honeywell,pressure-triplet: + description: | + Case-sensitive five character string that defines pressure range, unit + and type as part of the device nomenclature. In the unlikely case of a + custom chip, unset and provide pmin-pascal and pmax-pascal instead. + enum: [0001BA, 01.6BA, 02.5BA, 0060MG, 0100MG, 0160MG, 0250MG, 0400MG, + 0600MG, 0001BG, 01.6BG, 02.5BG, 0100KA, 0160KA, 0250KA, 0006KG, + 0010KG, 0016KG, 0025KG, 0040KG, 0060KG, 0100KG, 0160KG, 0250KG, + 0015PA, 0025PA, 0030PA, 0001PG, 0005PG, 0015PG, 0030PG, 0300YG] + $ref: /schemas/types.yaml#/definitions/string + + honeywell,pmin-pascal: + description: + Minimum pressure value the sensor can measure in pascal. + + honeywell,pmax-pascal: + description: + Maximum pressure value the sensor can measure in pascal. + vdd-supply: description: provide VDD power to the sensor. required: - compatible - reg - - honeywell,pmin-pascal - - honeywell,pmax-pascal - honeywell,transfer-function - vdd-supply +oneOf: + - required: + - honeywell,pressure-triplet + - required: + - honeywell,pmin-pascal + - honeywell,pmax-pascal + +allOf: + - if: + required: + - honeywell,pressure-triplet + then: + properties: + honeywell,pmin-pascal: false + honeywell,pmax-pascal: false + additionalProperties: false examples: @@ -99,8 +127,8 @@ examples: reset-gpios = <&gpio3 19 GPIO_ACTIVE_HIGH>; interrupt-parent = <&gpio3>; interrupts = <21 IRQ_TYPE_EDGE_RISING>; - honeywell,pmin-pascal = <0>; - honeywell,pmax-pascal = <172369>; + + honeywell,pressure-triplet = "0025PA"; honeywell,transfer-function = <1>; vdd-supply = <&vcc_3v3>; }; From patchwork Fri Dec 29 09:24:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petre Rodan X-Patchwork-Id: 183879 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp2466102dyb; Fri, 29 Dec 2023 01:26:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IEE8TbZDmuPurnrdadSP3KGCFJJV1l1iCTPbkdzFG/UTcdyh6ZYYNpMY7ATVDlpVCkFzW7p X-Received: by 2002:a05:6870:6589:b0:203:daf3:edc with SMTP id fp9-20020a056870658900b00203daf30edcmr12153855oab.53.1703841984199; Fri, 29 Dec 2023 01:26:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703841984; cv=none; d=google.com; s=arc-20160816; b=lyjK3fFH3i6TEMvGzrwHSBWH5UXdWx6qWVJo6Wq0FCd6GBHrVSWjCjDdOzcKjpeNer ED8f+xMumiy7dpErTHiNgr5K4xH328yCweI4VvfBcUVP6SKJG+KQ4o1pcZN6fIEly2nT N8SOkOAUL74Tdkyd4NXgyndOnfCEgmuAt+mVJqwWdT2ncPud6jYYAk+zhpVri3Up3zur XKKRnPjmCWoAA1WaypZib3q+JtTXQTEa+VJplTLza04Fb7QHP/VPLKj/F4smzCVznEW0 PxV690aaspJu+eeqEcSW807ZlBhcYicNOb2p3ZVBTi05fjQeRSr48FoDsSAwizdxPxr3 OzJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=qEIVXh5m17Ca4WCH0qEvEawKQwf92suAnQtsY1Qpl5k=; fh=jqBctGHbf9AVU5R58vhGWQ3B4pyO5m4xQP1pFNcmSHk=; b=wwrIiURWJHgx447pL2CJvTvntAWDIswBcCdpQKPB1R0nRBSKSRakcH5zJ5tYak/nme qqLhHpz99qkuDe+s0b/x9OPnEZJ5iPBuY8O7GwOTEcbI9lq5n5UqVQmBY/McYNz2jv/R VvTXlhaVO9Z+P1eoPfQhEt4B0Ni+OFlCulCgekAIkSCES/lWIALiw7bdD+rZ2OgGXDqL G1hBLsoyvncofpTFZbKBSa0pa+kqvcVB2p+FVr3nnSv2euI7b9Eu/n5Mdi0Vlcgpwnm3 0ASKYKZMVVjmp+9jlQ9Qo9b724jG9QwwBwRJJhR1oMSnqoV4QJzxEHJx/i3HZTROEtbD P1kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@subdimension.ro header.s=skycaves header.b=Bs3f2hKK; spf=pass (google.com: domain of linux-kernel+bounces-13029-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13029-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=subdimension.ro Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id c1-20020a654201000000b005c661524f67si13930175pgq.26.2023.12.29.01.26.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Dec 2023 01:26:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-13029-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@subdimension.ro header.s=skycaves header.b=Bs3f2hKK; spf=pass (google.com: domain of linux-kernel+bounces-13029-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13029-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=subdimension.ro Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id D8BEA281B41 for ; Fri, 29 Dec 2023 09:26:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5AEF011CBD; Fri, 29 Dec 2023 09:25:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=subdimension.ro header.i=@subdimension.ro header.b="Bs3f2hKK" X-Original-To: linux-kernel@vger.kernel.org Received: from mail.subdimension.ro (skycaves.subdimension.ro [172.104.132.142]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5373810A18; Fri, 29 Dec 2023 09:25:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=subdimension.ro Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=subdimension.ro Received: from localhost.localdomain (unknown [188.24.94.216]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mail.subdimension.ro (Postfix) with ESMTPSA id 9608728B53A; Fri, 29 Dec 2023 09:25:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=subdimension.ro; s=skycaves; t=1703841906; bh=YfYGIoUsTI6RzgUmUkVBpE+dj6lFzao+jS0AmTGN81E=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Bs3f2hKKzk/GN5rdiRahccBHXedBZeaRMfYOijRNv3atFnfBu0vgHc0bpf429z+/U /afaatpwBitxDxOuFQy/kTM5Gw72BNCdunkg6F4QZqg3UxoUA0EuUPamNn1cP/rmxt G3OuSnQQpleEN/3Eco7Z0H18znauBia+WVL4U9nI= From: Petre Rodan To: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Petre Rodan , Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Andy Shevchenko , Andreas Klinger Subject: [PATCH v3 03/10] dt-bindings: iio: pressure: honeywell,mprls0025pa.yaml add spi bus Date: Fri, 29 Dec 2023 11:24:31 +0200 Message-ID: <20231229092445.30180-4-petre.rodan@subdimension.ro> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231229092445.30180-1-petre.rodan@subdimension.ro> References: <20231229092445.30180-1-petre.rodan@subdimension.ro> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786607812549627105 X-GMAIL-MSGID: 1786607812549627105 Add spi based example. Add spi-max-frequency property required by chip specifications. Add additional maintainer. Co-developed-by: Andreas Klinger Signed-off-by: Andreas Klinger Signed-off-by: Petre Rodan Reviewed-by: Krzysztof Kozlowski --- v2 -> v3 add $ref: /schemas/spi/spi-peripheral-props.yaml .../iio/pressure/honeywell,mprls0025pa.yaml | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) -- 2.41.0 diff --git a/Documentation/devicetree/bindings/iio/pressure/honeywell,mprls0025pa.yaml b/Documentation/devicetree/bindings/iio/pressure/honeywell,mprls0025pa.yaml index 6643e51c481d..6994b30015bd 100644 --- a/Documentation/devicetree/bindings/iio/pressure/honeywell,mprls0025pa.yaml +++ b/Documentation/devicetree/bindings/iio/pressure/honeywell,mprls0025pa.yaml @@ -8,12 +8,12 @@ title: Honeywell mprls0025pa pressure sensor maintainers: - Andreas Klinger + - Petre Rodan description: | Honeywell pressure sensor of model mprls0025pa. - This sensor has an I2C and SPI interface. Only the I2C interface is - implemented. + This sensor has an I2C and SPI interface. There are many models with different pressure ranges available. The vendor calls them "mpr series". All of them have the identical programming model and @@ -86,6 +86,9 @@ properties: description: Maximum pressure value the sensor can measure in pascal. + spi-max-frequency: + maximum: 800000 + vdd-supply: description: provide VDD power to the sensor. @@ -103,6 +106,7 @@ oneOf: - honeywell,pmax-pascal allOf: + - $ref: /schemas/spi/spi-peripheral-props.yaml - if: required: - honeywell,pressure-triplet @@ -133,3 +137,22 @@ examples: vdd-supply = <&vcc_3v3>; }; }; + - | + spi { + #address-cells = <1>; + #size-cells = <0>; + + pressure@0 { + compatible = "honeywell,mprls0025pa"; + reg = <0>; + spi-max-frequency = <800000>; + reset-gpios = <&gpio1 28 GPIO_ACTIVE_HIGH>; + interrupt-parent = <&gpio0>; + interrupts = <30 IRQ_TYPE_EDGE_RISING>; + + honeywell,pressure-triplet = "0015PA"; + honeywell,transfer-function = <1>; + vdd-supply = <&vcc_3v3>; + }; + }; +... From patchwork Fri Dec 29 09:24:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petre Rodan X-Patchwork-Id: 183878 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp2466076dyb; Fri, 29 Dec 2023 01:26:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IE04rU3BYkveZjyBssNIHoC9hU7kvVK3Nju0FYWSTpMpGdrt3WbJy6bB5fUuY0PPkTFzge9 X-Received: by 2002:a05:6214:18d:b0:67f:de0c:1aa with SMTP id q13-20020a056214018d00b0067fde0c01aamr9954500qvr.123.1703841981364; Fri, 29 Dec 2023 01:26:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703841981; cv=none; d=google.com; s=arc-20160816; b=WuAZ1r+IM67VWryl5OEM0s02B48+LO/qAqdaS0Iw8m06I7tibDsUFiQ6g6ZuCdiMlJ zk8JoskGOX1c+eMnnvpAKuvtl72rEJrKIbbXEws1nldMkpPo2KqR9qcLsxtyX1Ap0ZaI FXsCYWJfY8s7rxDthVA/+e2OV4+nyudsw0TU1OA8itCidvqjVQhgAQ155G5A/9zCRVR9 8T8uXcwgbPPue/VU8mpVr7czOsJ1qlpccMF5hO1IMgW73IcGhm9AuAoixjdkmMkgfiEp C8l1eq6JvGWgZ91x/wXwRTTOqoomFfbDK1G2FqU7/eQxfuU1e2eFaXPF8wN//74rc2cF Z3gQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=O63f8/hzdyKes3hDJBK2oZxWoRpxJhe44nO6oTdF5To=; fh=cuSrpdmFbNnIGKLvcD6905UtzyKVEbJe+tTFY3eiseU=; b=UhSHggFeJQXgH8WCyt073EPY9VGzXJom5DnE1Lgq+peEjt5lDoPLLVrDtYn2hutZ9C xX7vXdTVDgCR35VfS1PoX5G80+PjVa8iz9lwewZRNwmR26RwauUoZklanxnRuGGF8BHB Pk0tvmtgY7raKL0hBBKy5UDn0HJ40SnJXIf5apBOqGkM2r5TlG4Agj3mzzDBbKM0aiOC H9Ok+oixQjdenJL+X0LBF27Sw0TA7Bs+DxoL//Za/7MnprJs1qekI7+eR3PVAYNaZCfy QbTniFlY2Ic7fwEu7L1XvycbPEgGl1pVgoOru/CNg0DDTZZrztYqj3STMsTGigE9sAOM MAXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@subdimension.ro header.s=skycaves header.b=m68GZYKJ; spf=pass (google.com: domain of linux-kernel+bounces-13028-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13028-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=subdimension.ro Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id m18-20020a05622a055200b004254e0e7245si18842209qtx.540.2023.12.29.01.26.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Dec 2023 01:26:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-13028-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@subdimension.ro header.s=skycaves header.b=m68GZYKJ; spf=pass (google.com: domain of linux-kernel+bounces-13028-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13028-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=subdimension.ro Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 2C4441C22DE2 for ; Fri, 29 Dec 2023 09:26:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3CB8911CB6; Fri, 29 Dec 2023 09:25:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=subdimension.ro header.i=@subdimension.ro header.b="m68GZYKJ" X-Original-To: linux-kernel@vger.kernel.org Received: from mail.subdimension.ro (skycaves.subdimension.ro [172.104.132.142]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 520C510A0A; Fri, 29 Dec 2023 09:25:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=subdimension.ro Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=subdimension.ro Received: from localhost.localdomain (unknown [188.24.94.216]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mail.subdimension.ro (Postfix) with ESMTPSA id 0286628B586; Fri, 29 Dec 2023 09:25:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=subdimension.ro; s=skycaves; t=1703841907; bh=tlhYys3P3yLGPXxjY35bhZAwm+PVbm6Qq70uWBAQSm8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=m68GZYKJYu9MVhSNNAhugzNP9Hjh9U5xoPyi8ZIdCy19klvpOuB3MGfceyHvae5HW YoQcUZMH9ESCm93nkGIh9jPTzbonbnlw8HtYFYLBrrSncnm8T/FsYacqwY8hyu99vJ gXjOwsgFOChM9ADJp8t5RVqynNHf45lVMJolEtSg= From: Petre Rodan To: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Petre Rodan , Andreas Klinger , Jonathan Cameron , Lars-Peter Clausen , Andy Shevchenko , Angel Iglesias , Matti Vaittinen Subject: [PATCH v3 04/10] iio: pressure: mprls0025pa fix off-by-one enum Date: Fri, 29 Dec 2023 11:24:32 +0200 Message-ID: <20231229092445.30180-5-petre.rodan@subdimension.ro> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231229092445.30180-1-petre.rodan@subdimension.ro> References: <20231229092445.30180-1-petre.rodan@subdimension.ro> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786607809101577511 X-GMAIL-MSGID: 1786607809101577511 Fix off-by-one error in transfer-function property. The honeywell,transfer-function property takes values between 1-3 so make sure the proper enum gets used. Fixes: <713337d9143ed> ("iio: pressure: Honeywell mprls0025pa pressure sensor") Co-developed-by: Andreas Klinger Signed-off-by: Andreas Klinger Signed-off-by: Petre Rodan --- v2 -> v3 no changes drivers/iio/pressure/mprls0025pa.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) -- 2.41.0 diff --git a/drivers/iio/pressure/mprls0025pa.c b/drivers/iio/pressure/mprls0025pa.c index 30fb2de36821..e3f0de020a40 100644 --- a/drivers/iio/pressure/mprls0025pa.c +++ b/drivers/iio/pressure/mprls0025pa.c @@ -323,6 +323,7 @@ static int mpr_probe(struct i2c_client *client) struct iio_dev *indio_dev; struct device *dev = &client->dev; s64 scale, offset; + u32 func; if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_READ_BYTE)) return dev_err_probe(dev, -EOPNOTSUPP, @@ -362,10 +363,11 @@ static int mpr_probe(struct i2c_client *client) return dev_err_probe(dev, ret, "honeywell,pmax-pascal could not be read\n"); ret = device_property_read_u32(dev, - "honeywell,transfer-function", &data->function); + "honeywell,transfer-function", &func); if (ret) return dev_err_probe(dev, ret, "honeywell,transfer-function could not be read\n"); + data->function = func - 1; if (data->function > MPR_FUNCTION_C) return dev_err_probe(dev, -EINVAL, "honeywell,transfer-function %d invalid\n", From patchwork Fri Dec 29 09:24:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petre Rodan X-Patchwork-Id: 183881 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp2466425dyb; Fri, 29 Dec 2023 01:27:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IGwTP8s3YHGJzd3AVT+B9jloxh7eqw3GrFoBIne+sy51riojEcbXaJFw3VIeA/fIq+QNpsI X-Received: by 2002:ae9:f40d:0:b0:781:5be4:b3fe with SMTP id y13-20020ae9f40d000000b007815be4b3femr5467613qkl.71.1703842048931; Fri, 29 Dec 2023 01:27:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703842048; cv=none; d=google.com; s=arc-20160816; b=yInbBOQphxj13jLx7WSoKZK19AkcypBy7/mFvD6p4EIzO6Tsvm8+xd/OW1K5Yc3LJB NVTDIx8w9fa7MdDqK3WzVP1iahFJnQz3KFXHth5UYT1Bch8x0SkYRo3Ip0NW2c9SU2rb qQgbS/7dg5Fdk58xAtjStiy0Opecp5Mpz9J5wG+VNWDIFmkf8hNIN2om2z4IoC5n6JDN sDcIZoOMtK1iPutUkyIlFkvaCiPSzYbEuxWIr3dMex59N4m//36th9AFHhwLfrB7Rh8/ eXrxeGcGw4ajAM/ntx1rcgwX8Sh2Cxh4+X8bVOSrze576EnKUOzpaORNfccubDTjDRSN O5bA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=8UnxNb10S0yXPkPLRZ/mgeEJI3f6GIksHWzAJ6/qZ3U=; fh=cuSrpdmFbNnIGKLvcD6905UtzyKVEbJe+tTFY3eiseU=; b=iBzNuYJ2B3KXmDE7Ra2OLvnFaW/D/14ir07X9Oy7Uqz/bTRsg1Y9CQ3C+hijjP+glv wWCOYypAN5RkCMGqvjIVUwyFAgMHvLvbKaaXhVi+SMVObG7Fyjd0qMBzE3Yhh1tVsJWh Z/VIDzktfmn7xOT/DZfuZ30ggItRRwHEuYgVOjasba8ABoxSW1Xtr8zuXdDH2e3ZAkJf ZPs22mmWcv19rp2qDBrBCZrBXVulQy2xGwKIjWsUMz9XIWxwxPvTPn3NiZ8UN+0Um+86 O4ugi6iUX/lizLMzQXDjHIDYrK8x6w5QuqE6oSAcnLDEWeuKz+EiW5JyiLETBphnJGV4 WylQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@subdimension.ro header.s=skycaves header.b=mIaJW9MP; spf=pass (google.com: domain of linux-kernel+bounces-13032-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13032-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=subdimension.ro Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id b38-20020a05620a272600b0078162b73363si4960485qkp.15.2023.12.29.01.27.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Dec 2023 01:27:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-13032-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@subdimension.ro header.s=skycaves header.b=mIaJW9MP; spf=pass (google.com: domain of linux-kernel+bounces-13032-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13032-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=subdimension.ro Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id B6C6B1C2239A for ; Fri, 29 Dec 2023 09:27:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1CF21134A7; Fri, 29 Dec 2023 09:25:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=subdimension.ro header.i=@subdimension.ro header.b="mIaJW9MP" X-Original-To: linux-kernel@vger.kernel.org Received: from mail.subdimension.ro (skycaves.subdimension.ro [172.104.132.142]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AD29611707; Fri, 29 Dec 2023 09:25:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=subdimension.ro Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=subdimension.ro Received: from localhost.localdomain (unknown [188.24.94.216]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mail.subdimension.ro (Postfix) with ESMTPSA id 581A028B587; Fri, 29 Dec 2023 09:25:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=subdimension.ro; s=skycaves; t=1703841907; bh=WDPOUW7eIikkHeG8X4wBbQ+EIdwGrEaQcqnAsLeHEGg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=mIaJW9MPIiNCMyBoEfJRjdEiuJ4AhJe0o9TNUvAraFysQ+wSv77fr7hU1NTmS6Usj 74htdF0yGWbcKsPFMKoGHbG0CFJBfYNxzwlRoR9wPSHYKAJUGpp2CV+M9wrI9UdFQ8 7u03koibqsE3BNczxn3udLHD5v1Ajp6dksPUKHwA= From: Petre Rodan To: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Petre Rodan , Andreas Klinger , Jonathan Cameron , Lars-Peter Clausen , Andy Shevchenko , Angel Iglesias , Matti Vaittinen Subject: [PATCH v3 05/10] iio: pressure: mprls0025pa improve driver error resilience Date: Fri, 29 Dec 2023 11:24:33 +0200 Message-ID: <20231229092445.30180-6-petre.rodan@subdimension.ro> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231229092445.30180-1-petre.rodan@subdimension.ro> References: <20231229092445.30180-1-petre.rodan@subdimension.ro> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786607880301098184 X-GMAIL-MSGID: 1786607880301098184 Improve driver error resilience by ignoring the measurement if any of the 3 error flags gets set while interacting with the sensor. Based on the datasheet, in table 14 on page 14, the status byte contains: bit 5 busy flag - 1 if device is busy bit 2 memory integrity/error flag - 1 if integrity test failed bit 0 math saturation - 1 if internal math saturation has occurred Co-developed-by: Andreas Klinger Signed-off-by: Andreas Klinger Signed-off-by: Petre Rodan --- v2 -> v3 no changes drivers/iio/pressure/mprls0025pa.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) -- 2.41.0 diff --git a/drivers/iio/pressure/mprls0025pa.c b/drivers/iio/pressure/mprls0025pa.c index e3f0de020a40..233cc1dc38ad 100644 --- a/drivers/iio/pressure/mprls0025pa.c +++ b/drivers/iio/pressure/mprls0025pa.c @@ -39,6 +39,8 @@ #define MPR_I2C_MEMORY BIT(2) /* integrity test passed */ #define MPR_I2C_MATH BIT(0) /* internal math saturation */ +#define MPR_I2C_ERR_FLAG (MPR_I2C_BUSY | MPR_I2C_MEMORY | MPR_I2C_MATH) + /* * support _RAW sysfs interface: * @@ -213,7 +215,7 @@ static int mpr_read_pressure(struct mpr_data *data, s32 *press) status); return status; } - if (!(status & MPR_I2C_BUSY)) + if (!(status & MPR_I2C_ERR_FLAG)) break; } if (i == nloops) { @@ -233,7 +235,7 @@ static int mpr_read_pressure(struct mpr_data *data, s32 *press) return -EIO; } - if (buf[0] & MPR_I2C_BUSY) { + if (buf[0] & MPR_I2C_ERR_FLAG) { /* * it should never be the case that status still indicates * business From patchwork Fri Dec 29 09:24:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petre Rodan X-Patchwork-Id: 183885 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp2466929dyb; Fri, 29 Dec 2023 01:29:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IFBvrLdHy//kUNamYRsGcaIqHbRlDJFrEPBgwe3LYFdzAeKpj3VyXzmxM3VN3ro42jO7STD X-Received: by 2002:a17:903:2283:b0:1d4:9671:f15c with SMTP id b3-20020a170903228300b001d49671f15cmr1873337plh.88.1703842149913; Fri, 29 Dec 2023 01:29:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703842149; cv=none; d=google.com; s=arc-20160816; b=ysKf+2BPjcLlhnkP1CrwzJZQaP3s84ySCk+Hw9eUD0URT1zxlOmi1nmjakcEtf0+GK iwtseGbHkqf46STK51AH6o9/hj8YBv6ifnhzgV1DFrsrxrtjzjCL30TLCRgx33Dkrqa5 0k7EyAdkBS+I69lLeOTgVC9hwcKqmMqiMEJGv+5mgdoOzQ9sVddbAsjebc0EQqXMDAaT lKoErVjlLEUzGRt7l5YEEEE9hEkDGw7zoIQzu/OVjBR07xJXI2F/ptONiPYeDDEACNHc p1mv+EpLnz1MiR3rn+CmLG85Zi8yPC+39yqrfIu0nVBrfClil/vx3SagHScGdwd2ngwF te3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=4CPc072cphdKuDuAHDK3JYBuTeNxIRsUN+ltDBLASnQ=; fh=cuSrpdmFbNnIGKLvcD6905UtzyKVEbJe+tTFY3eiseU=; b=CPqS09ea30wcK+QXEejVP5u4lyI6k3s1i2hTr0kZiEJX/d8Pwjy/pBVFEE3WHKXTpW 9SSFC4nP5FQ/0yXi1yrebG+iCTEuSdkIlTlR2Kcs5MgeKSTGxiEf0cajcdd/FvhiNnfY C8yEVkETQWAxLmyMoMuixBShVGr3DzSp0TMceH5NlZZg4McG6grRi0icE6YObIxEgSJ8 K66lyjbKOSIXZX14HDTLynxMvok8Ll8e+N3j91ghs26QF4lG2JH0AtGmk76ndBuHlBXI 01xsAz/vCUWL5glErWusK0P/Hl2Y9PsI63IuCwpNtCR6jypTY3V5lzn6/qzStfP+nHga 9xCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@subdimension.ro header.s=skycaves header.b="Q6iGt/rq"; spf=pass (google.com: domain of linux-kernel+bounces-13031-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13031-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=subdimension.ro Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id m11-20020a170902db0b00b001d4752f5408si5560081plx.491.2023.12.29.01.29.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Dec 2023 01:29:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-13031-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@subdimension.ro header.s=skycaves header.b="Q6iGt/rq"; spf=pass (google.com: domain of linux-kernel+bounces-13031-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13031-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=subdimension.ro Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id D99C0B23040 for ; Fri, 29 Dec 2023 09:27:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1CF4A134A8; Fri, 29 Dec 2023 09:25:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=subdimension.ro header.i=@subdimension.ro header.b="Q6iGt/rq" X-Original-To: linux-kernel@vger.kernel.org Received: from mail.subdimension.ro (skycaves.subdimension.ro [172.104.132.142]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6D1D9111B2; Fri, 29 Dec 2023 09:25:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=subdimension.ro Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=subdimension.ro Received: from localhost.localdomain (unknown [188.24.94.216]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mail.subdimension.ro (Postfix) with ESMTPSA id AD3EC28B589; Fri, 29 Dec 2023 09:25:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=subdimension.ro; s=skycaves; t=1703841907; bh=u3xyd+nm/UZuOc3ZGkrOgUgkrAV7H1N45wZ4bM46qHI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Q6iGt/rqPO/JT9MpC9yAhsdDth9McjbYCHpUsFU9C8BX7RCcKSvlXmz4AbhqdmDiQ 6InniD54xqzIL/taHDRqyoPG4bh6WF5yfeX3vJKIR9QxBuB5IREQ8gEJBs7KahBC1V GIDUsQrlynv466geO7D3L8QNRbRIXgQgdU4m8LA0= From: Petre Rodan To: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Petre Rodan , Andreas Klinger , Jonathan Cameron , Lars-Peter Clausen , Andy Shevchenko , Angel Iglesias , Matti Vaittinen Subject: [PATCH v3 06/10] iio: pressure: mprls0025pa remove defaults Date: Fri, 29 Dec 2023 11:24:34 +0200 Message-ID: <20231229092445.30180-7-petre.rodan@subdimension.ro> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231229092445.30180-1-petre.rodan@subdimension.ro> References: <20231229092445.30180-1-petre.rodan@subdimension.ro> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786607986291644114 X-GMAIL-MSGID: 1786607986291644114 This driver supports 32*3 combinations of fixed ranges and transfer functions, plus custom ranges. So statistically a user has more than 99% chance that the provided default configuration will generate invalid pressure readings if the bindings are not initialized and the driver is instantiated via sysfs. The current patch removes this loophole making sure the driver loads only if the firmware properties are present. Co-developed-by: Andreas Klinger Signed-off-by: Andreas Klinger Signed-off-by: Petre Rodan --- v2 -> v3 drop the use of dev_fwnode() entirely drivers/iio/pressure/mprls0025pa.c | 48 +++++++++++++----------------- 1 file changed, 20 insertions(+), 28 deletions(-) -- 2.41.0 diff --git a/drivers/iio/pressure/mprls0025pa.c b/drivers/iio/pressure/mprls0025pa.c index 233cc1dc38ad..e0a2a60c6245 100644 --- a/drivers/iio/pressure/mprls0025pa.c +++ b/drivers/iio/pressure/mprls0025pa.c @@ -353,34 +353,26 @@ static int mpr_probe(struct i2c_client *client) return dev_err_probe(dev, ret, "can't get and enable vdd supply\n"); - if (dev_fwnode(dev)) { - ret = device_property_read_u32(dev, "honeywell,pmin-pascal", - &data->pmin); - if (ret) - return dev_err_probe(dev, ret, - "honeywell,pmin-pascal could not be read\n"); - ret = device_property_read_u32(dev, "honeywell,pmax-pascal", - &data->pmax); - if (ret) - return dev_err_probe(dev, ret, - "honeywell,pmax-pascal could not be read\n"); - ret = device_property_read_u32(dev, - "honeywell,transfer-function", &func); - if (ret) - return dev_err_probe(dev, ret, - "honeywell,transfer-function could not be read\n"); - data->function = func - 1; - if (data->function > MPR_FUNCTION_C) - return dev_err_probe(dev, -EINVAL, - "honeywell,transfer-function %d invalid\n", - data->function); - } else { - /* when loaded as i2c device we need to use default values */ - dev_notice(dev, "firmware node not found; using defaults\n"); - data->pmin = 0; - data->pmax = 172369; /* 25 psi */ - data->function = MPR_FUNCTION_A; - } + ret = device_property_read_u32(dev, "honeywell,pmin-pascal", + &data->pmin); + if (ret) + return dev_err_probe(dev, ret, + "honeywell,pmin-pascal could not be read\n"); + ret = device_property_read_u32(dev, "honeywell,pmax-pascal", + &data->pmax); + if (ret) + return dev_err_probe(dev, ret, + "honeywell,pmax-pascal could not be read\n"); + ret = device_property_read_u32(dev, + "honeywell,transfer-function", &func); + if (ret) + return dev_err_probe(dev, ret, + "honeywell,transfer-function could not be read\n"); + data->function = func - 1; + if (data->function > MPR_FUNCTION_C) + return dev_err_probe(dev, -EINVAL, + "honeywell,transfer-function %d invalid\n", + data->function); data->outmin = mpr_func_spec[data->function].output_min; data->outmax = mpr_func_spec[data->function].output_max; From patchwork Fri Dec 29 09:24:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petre Rodan X-Patchwork-Id: 183882 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp2466438dyb; Fri, 29 Dec 2023 01:27:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IG/Sn/fbuDDu30saET7Gk5vtPCDcD0XararqO/fpB7cGBzFsx7yKdmyY4ub3Myu0uGSY1VK X-Received: by 2002:a05:620a:1905:b0:781:6b43:1203 with SMTP id bj5-20020a05620a190500b007816b431203mr3645432qkb.155.1703842051315; Fri, 29 Dec 2023 01:27:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703842051; cv=none; d=google.com; s=arc-20160816; b=FBqTY1+2sqinVxq2JA4N8ABrhR4APXSewBSIKcOe+9zqe7ZcSpiuEin0m4y9WRihzt BWQL9lG5Ag+ZrO/g3UU8ik0p4oouzU/h72GFq0hf7nUNNRHrGqj/Was/5oKQE1O1A6/o tL5mq6fGPA4mTPfAS/kixKewKHz1RENVBfoKG5G2HRrZyzUsl4XzT0rsYGn/lA37p0c/ IZxp2Bk5E3UgjDLg7Jh6t5MR2bXU3fWKdqlVL8t7xnhY1oPwHmGjrxxSPlz8iJszmLml 9TUiO3WeoxYYQSROA6VE6kZqcG2xzCeJIj/BJv19sVAmqBXYskh6GNu6lnhy1qZnT9MS ri/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=lpgUw79UoIRuJUHgJgVPdoZ1f363FlaTiO3Kgf4Q2uM=; fh=cuSrpdmFbNnIGKLvcD6905UtzyKVEbJe+tTFY3eiseU=; b=oul+dRd56TMA14K4k5JJ1JsXuA6Ev54gepnDjbNA6sBkPNVKuN0nOMjOfKx1BU4rS6 MDHhpkmmyPDXKL2WurVVqL1366wgnMOLjbLiG6tI8YWkcQ2KWhN3UTzhMA+Gv/QIq96Q FRWYP/hJlMZCFJB6daRh906897MG/7AmRrt9cH+4GezOpo2BGnQIOqBEKulsRq6Iy/U/ /oM7JK+Yc4XIRDZ4IvjC+neYont4iF/GhENp0+eBYjsRKx+DXQhIhILe1zuo/Z64NdGN +Zb5ePAs+NSMKAO8kjFOOE02gwn5U6qiFVr2eW99CWpI9WWJjWJ9Wl0TBa9/S7hW3w+W ntKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@subdimension.ro header.s=skycaves header.b=hHS9P2KP; spf=pass (google.com: domain of linux-kernel+bounces-13033-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13033-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=subdimension.ro Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id de11-20020a05620a370b00b0077f56993a3esi19859915qkb.377.2023.12.29.01.27.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Dec 2023 01:27:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-13033-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@subdimension.ro header.s=skycaves header.b=hHS9P2KP; spf=pass (google.com: domain of linux-kernel+bounces-13033-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13033-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=subdimension.ro Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 11F9B1C212C5 for ; Fri, 29 Dec 2023 09:27:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3A6A6134AF; Fri, 29 Dec 2023 09:25:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=subdimension.ro header.i=@subdimension.ro header.b="hHS9P2KP" X-Original-To: linux-kernel@vger.kernel.org Received: from mail.subdimension.ro (skycaves.subdimension.ro [172.104.132.142]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AC1A811705; Fri, 29 Dec 2023 09:25:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=subdimension.ro Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=subdimension.ro Received: from localhost.localdomain (unknown [188.24.94.216]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mail.subdimension.ro (Postfix) with ESMTPSA id 0F40828B594; Fri, 29 Dec 2023 09:25:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=subdimension.ro; s=skycaves; t=1703841908; bh=vBr77PlPfMNs1GvByaNmBP3bSQKIkAVW8QSD0Z9L7pE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=hHS9P2KP1Uvpka4tk/Dvb79Hfo9X9pFFVQIkvPUgl8/3hNni6Y2fpJtBa0UwuTmOm EgWZC/oHBS+HWmgnK2xqE9uW+/XY/6m3sBbV1QI3CH3fueFdOLvaeNLYOfL+XrvnuE 0aauagJdKOKMKbyZR8uJ7cKVGrjsXsC9GdMNuvYI= From: Petre Rodan To: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Petre Rodan , Andreas Klinger , Jonathan Cameron , Lars-Peter Clausen , Andy Shevchenko , Angel Iglesias , Matti Vaittinen Subject: [PATCH v3 07/10] iio: pressure: mprls0025pa whitespace cleanup Date: Fri, 29 Dec 2023 11:24:35 +0200 Message-ID: <20231229092445.30180-8-petre.rodan@subdimension.ro> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231229092445.30180-1-petre.rodan@subdimension.ro> References: <20231229092445.30180-1-petre.rodan@subdimension.ro> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786607882858023429 X-GMAIL-MSGID: 1786607882858023429 Fix indentation and whitespace in code that will not get refactored. Make URL inside comment copy-paste friendly. Co-developed-by: Andreas Klinger Signed-off-by: Andreas Klinger Signed-off-by: Petre Rodan --- v2 -> v3 even more whitespace drivers/iio/pressure/mprls0025pa.c | 35 +++++++++++++++--------------- 1 file changed, 17 insertions(+), 18 deletions(-) -- 2.41.0 diff --git a/drivers/iio/pressure/mprls0025pa.c b/drivers/iio/pressure/mprls0025pa.c index e0a2a60c6245..fef3ca69c4f0 100644 --- a/drivers/iio/pressure/mprls0025pa.c +++ b/drivers/iio/pressure/mprls0025pa.c @@ -5,10 +5,7 @@ * Copyright (c) Andreas Klinger * * Data sheet: - * https://prod-edam.honeywell.com/content/dam/honeywell-edam/sps/siot/en-us/ - * products/sensors/pressure-sensors/board-mount-pressure-sensors/ - * micropressure-mpr-series/documents/ - * sps-siot-mpr-series-datasheet-32332628-ciid-172626.pdf + * https://prod-edam.honeywell.com/content/dam/honeywell-edam/sps/siot/en-us/products/sensors/pressure-sensors/board-mount-pressure-sensors/micropressure-mpr-series/documents/sps-siot-mpr-series-datasheet-32332628-ciid-172626.pdf * * 7-bit I2C default slave address: 0x18 */ @@ -84,9 +81,9 @@ struct mpr_func_spec { }; static const struct mpr_func_spec mpr_func_spec[] = { - [MPR_FUNCTION_A] = {.output_min = 1677722, .output_max = 15099494}, - [MPR_FUNCTION_B] = {.output_min = 419430, .output_max = 3774874}, - [MPR_FUNCTION_C] = {.output_min = 3355443, .output_max = 13421773}, + [MPR_FUNCTION_A] = { .output_min = 1677722, .output_max = 15099494 }, + [MPR_FUNCTION_B] = { .output_min = 419430, .output_max = 3774874 }, + [MPR_FUNCTION_C] = { .output_min = 3355443, .output_max = 13421773 }, }; struct mpr_chan { @@ -273,7 +270,7 @@ static irqreturn_t mpr_trigger_handler(int irq, void *p) goto err; iio_push_to_buffers_with_timestamp(indio_dev, &data->chan, - iio_get_time_ns(indio_dev)); + iio_get_time_ns(indio_dev)); err: mutex_unlock(&data->lock); @@ -351,7 +348,7 @@ static int mpr_probe(struct i2c_client *client) ret = devm_regulator_get_enable(dev, "vdd"); if (ret) return dev_err_probe(dev, ret, - "can't get and enable vdd supply\n"); + "can't get and enable vdd supply\n"); ret = device_property_read_u32(dev, "honeywell,pmin-pascal", &data->pmin); @@ -379,42 +376,44 @@ static int mpr_probe(struct i2c_client *client) /* use 64 bit calculation for preserving a reasonable precision */ scale = div_s64(((s64)(data->pmax - data->pmin)) * NANO, - data->outmax - data->outmin); + data->outmax - data->outmin); data->scale = div_s64_rem(scale, NANO, &data->scale2); /* * multiply with NANO before dividing by scale and later divide by NANO * again. */ offset = ((-1LL) * (s64)data->outmin) * NANO - - div_s64(div_s64((s64)data->pmin * NANO, scale), NANO); + div_s64(div_s64((s64)data->pmin * NANO, scale), NANO); data->offset = div_s64_rem(offset, NANO, &data->offset2); if (data->irq > 0) { ret = devm_request_irq(dev, data->irq, mpr_eoc_handler, - IRQF_TRIGGER_RISING, client->name, data); + IRQF_TRIGGER_RISING, + client->name, + data); if (ret) return dev_err_probe(dev, ret, - "request irq %d failed\n", data->irq); + "request irq %d failed\n", data->irq); } data->gpiod_reset = devm_gpiod_get_optional(dev, "reset", - GPIOD_OUT_HIGH); + GPIOD_OUT_HIGH); if (IS_ERR(data->gpiod_reset)) return dev_err_probe(dev, PTR_ERR(data->gpiod_reset), - "request reset-gpio failed\n"); + "request reset-gpio failed\n"); mpr_reset(data); ret = devm_iio_triggered_buffer_setup(dev, indio_dev, NULL, - mpr_trigger_handler, NULL); + mpr_trigger_handler, NULL); if (ret) return dev_err_probe(dev, ret, - "iio triggered buffer setup failed\n"); + "iio triggered buffer setup failed\n"); ret = devm_iio_device_register(dev, indio_dev); if (ret) return dev_err_probe(dev, ret, - "unable to register iio device\n"); + "unable to register iio device\n"); return 0; } From patchwork Fri Dec 29 09:24:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petre Rodan X-Patchwork-Id: 183883 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp2466485dyb; Fri, 29 Dec 2023 01:27:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IGRcl0koE07JSwOaRDNKlhlX9AUnDuGNnAB+Fsec0JBNdt0Da3jdxydW5oC+oHlyX+zELmq X-Received: by 2002:a50:a6d1:0:b0:554:72e7:f72d with SMTP id f17-20020a50a6d1000000b0055472e7f72dmr4115742edc.17.1703842057726; Fri, 29 Dec 2023 01:27:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703842057; cv=none; d=google.com; s=arc-20160816; b=DHjgp2brnBZrc4ZLtnaaEUYWO/zX7LuMncEgOGDIzhBCoLFF0wX2ujOCwrdBAcW6Bq j9AJNjkp7Qryw1eIwMOsPczG/1gplEb6qlIQKV8aghSO1qFowbKI2lbyXMeedfYYffjO vkvSICOofQCHfSr585eWQOfXAyqa1HZQnUhTpMTsiN76v/5ctzSbUndX86CM9xzwF8/X Ws+AEjqeAWyjj+CvjJwkmUdGS4qFdoTCTFhVx79Rr8mn/20zvBIxqfzeEb2WmdEbUJSV 7LRQ0M8QnbP7O5ez2nrYZXNynVsBGTEUTXuy96qAd5zKeXLaDoWF1SmV7zzEdAyQ/cjH kaTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=ZlQvLqcgpBA3vVZvgaA40Ny0HnfeJ/L9VxxYOmN8tPo=; fh=cuSrpdmFbNnIGKLvcD6905UtzyKVEbJe+tTFY3eiseU=; b=PS+T9NVU77ZVnr2GPTmN7NINaaUns0BZG3v8GkI40DT+jPhUzW5WNpkVvpFQrrCnap oiJWM8CSWZg5BvHDVq5CSEeMNAX9lCRg29c/ZpdE4Tm6ICvYHxsQl+AN4m8/2fBD+1ym wSdNxYNXtkR0SSG1vGPtQAozlp+uKDZA08nG5DhID0SLtWXW6BQzSOs2iIK4bUvNTgG5 tAd8AYZvxGDl4Nhm7ylNXd+/QGYxnXhKR7op8bWOG9DXSypMholywW9CyGQGWgdP/CKh 7DJ2YFh72AHho5Pf+ut3c06ZiHVzb4T8fm8xH8MdQCjDD40llW3jUkHnUJb2FRMJZ9kN zZ0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@subdimension.ro header.s=skycaves header.b=UI1xsGjr; spf=pass (google.com: domain of linux-kernel+bounces-13034-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13034-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=subdimension.ro Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id r7-20020a50aac7000000b00555aaf3b59fsi794812edc.5.2023.12.29.01.27.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Dec 2023 01:27:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-13034-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@subdimension.ro header.s=skycaves header.b=UI1xsGjr; spf=pass (google.com: domain of linux-kernel+bounces-13034-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13034-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=subdimension.ro Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 2370A1F211A3 for ; Fri, 29 Dec 2023 09:27:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 75869134BE; Fri, 29 Dec 2023 09:25:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=subdimension.ro header.i=@subdimension.ro header.b="UI1xsGjr" X-Original-To: linux-kernel@vger.kernel.org Received: from mail.subdimension.ro (skycaves.subdimension.ro [172.104.132.142]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ACFDD11706; Fri, 29 Dec 2023 09:25:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=subdimension.ro Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=subdimension.ro Received: from localhost.localdomain (unknown [188.24.94.216]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mail.subdimension.ro (Postfix) with ESMTPSA id 6562628B595; Fri, 29 Dec 2023 09:25:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=subdimension.ro; s=skycaves; t=1703841908; bh=uVNtoi/xlIooFvtiZdQkkyKTU/TJj7vANPZ95QWrAAg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=UI1xsGjrQyPVYFc+wKvH3cc5P4TVTpDCgEwDosqmUiJ7VxFILVqcdUBVWHLlJFWQj njbNZOFkZQs8RQ4pyCk9rBX6mFkuwyzVhBTL+zWcCY6WvbHkLdzehJTcq+N5bnyYwy Vd+x7+LkQyQIaFQDyxIawi5gtIvYfvHvPMhllrVo= From: Petre Rodan To: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Petre Rodan , Andreas Klinger , Jonathan Cameron , Lars-Peter Clausen , Andy Shevchenko , Angel Iglesias , Matti Vaittinen Subject: [PATCH v3 08/10] iio: pressure: mprls0025pa refactor Date: Fri, 29 Dec 2023 11:24:36 +0200 Message-ID: <20231229092445.30180-9-petre.rodan@subdimension.ro> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231229092445.30180-1-petre.rodan@subdimension.ro> References: <20231229092445.30180-1-petre.rodan@subdimension.ro> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786607889300979706 X-GMAIL-MSGID: 1786607889300979706 Refactor driver by splitting the code into core and i2c. Seemingly redundant read/write function parameters are required for compatibility with the SPI driver. Co-developed-by: Andreas Klinger Signed-off-by: Andreas Klinger Signed-off-by: Petre Rodan --- v2 -> v3 move '#include ' to mprls0025pa.h fix checkpatch.pl warnings related to mprls0025pa.h MAINTAINERS | 3 +- drivers/iio/pressure/Kconfig | 6 + drivers/iio/pressure/Makefile | 1 + drivers/iio/pressure/mprls0025pa.c | 185 +++++++------------------ drivers/iio/pressure/mprls0025pa.h | 102 ++++++++++++++ drivers/iio/pressure/mprls0025pa_i2c.c | 98 +++++++++++++ 6 files changed, 262 insertions(+), 133 deletions(-) create mode 100644 drivers/iio/pressure/mprls0025pa.h create mode 100644 drivers/iio/pressure/mprls0025pa_i2c.c -- 2.41.0 diff --git a/MAINTAINERS b/MAINTAINERS index a31b1b20c6f6..77ee0b4d9f73 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -9686,10 +9686,11 @@ F: drivers/iio/pressure/hsc030pa* HONEYWELL MPRLS0025PA PRESSURE SENSOR SERIES IIO DRIVER M: Andreas Klinger +M: Petre Rodan L: linux-iio@vger.kernel.org S: Maintained F: Documentation/devicetree/bindings/iio/pressure/honeywell,mprls0025pa.yaml -F: drivers/iio/pressure/mprls0025pa.c +F: drivers/iio/pressure/mprls0025pa* HOST AP DRIVER L: linux-wireless@vger.kernel.org diff --git a/drivers/iio/pressure/Kconfig b/drivers/iio/pressure/Kconfig index 79adfd059c3a..f03007cfec85 100644 --- a/drivers/iio/pressure/Kconfig +++ b/drivers/iio/pressure/Kconfig @@ -182,6 +182,7 @@ config MPL3115 config MPRLS0025PA tristate "Honeywell MPRLS0025PA (MicroPressure sensors series)" depends on I2C + select MPRLS0025PA_I2C if I2C select IIO_BUFFER select IIO_TRIGGERED_BUFFER help @@ -192,6 +193,11 @@ config MPRLS0025PA To compile this driver as a module, choose M here: the module will be called mprls0025pa. +config MPRLS0025PA_I2C + tristate + depends on MPRLS0025PA + depends on I2C + config MS5611 tristate "Measurement Specialties MS5611 pressure sensor driver" select IIO_BUFFER diff --git a/drivers/iio/pressure/Makefile b/drivers/iio/pressure/Makefile index b0f8b94662f2..7754135e190c 100644 --- a/drivers/iio/pressure/Makefile +++ b/drivers/iio/pressure/Makefile @@ -24,6 +24,7 @@ obj-$(CONFIG_MPL115_I2C) += mpl115_i2c.o obj-$(CONFIG_MPL115_SPI) += mpl115_spi.o obj-$(CONFIG_MPL3115) += mpl3115.o obj-$(CONFIG_MPRLS0025PA) += mprls0025pa.o +obj-$(CONFIG_MPRLS0025PA_I2C) += mprls0025pa_i2c.o obj-$(CONFIG_MS5611) += ms5611_core.o obj-$(CONFIG_MS5611_I2C) += ms5611_i2c.o obj-$(CONFIG_MS5611_SPI) += ms5611_spi.o diff --git a/drivers/iio/pressure/mprls0025pa.c b/drivers/iio/pressure/mprls0025pa.c index fef3ca69c4f0..ce20cf362fac 100644 --- a/drivers/iio/pressure/mprls0025pa.c +++ b/drivers/iio/pressure/mprls0025pa.c @@ -7,12 +7,11 @@ * Data sheet: * https://prod-edam.honeywell.com/content/dam/honeywell-edam/sps/siot/en-us/products/sensors/pressure-sensors/board-mount-pressure-sensors/micropressure-mpr-series/documents/sps-siot-mpr-series-datasheet-32332628-ciid-172626.pdf * - * 7-bit I2C default slave address: 0x18 */ -#include -#include -#include +#include +#include +#include #include #include #include @@ -22,7 +21,6 @@ #include #include -#include #include #include @@ -30,13 +28,15 @@ #include -/* bits in i2c status byte */ -#define MPR_I2C_POWER BIT(6) /* device is powered */ -#define MPR_I2C_BUSY BIT(5) /* device is busy */ -#define MPR_I2C_MEMORY BIT(2) /* integrity test passed */ -#define MPR_I2C_MATH BIT(0) /* internal math saturation */ +#include "mprls0025pa.h" -#define MPR_I2C_ERR_FLAG (MPR_I2C_BUSY | MPR_I2C_MEMORY | MPR_I2C_MATH) +/* bits in status byte */ +#define MPR_ST_POWER BIT(6) /* device is powered */ +#define MPR_ST_BUSY BIT(5) /* device is busy */ +#define MPR_ST_MEMORY BIT(2) /* integrity test passed */ +#define MPR_ST_MATH BIT(0) /* internal math saturation */ + +#define MPR_ST_ERR_FLAG (MPR_ST_BUSY | MPR_ST_MEMORY | MPR_ST_MATH) /* * support _RAW sysfs interface: @@ -69,12 +69,6 @@ * transfer function B: 2.5% to 22.5% of 2^24 * transfer function C: 20% to 80% of 2^24 */ -enum mpr_func_id { - MPR_FUNCTION_A, - MPR_FUNCTION_B, - MPR_FUNCTION_C, -}; - struct mpr_func_spec { u32 output_min; u32 output_max; @@ -86,45 +80,6 @@ static const struct mpr_func_spec mpr_func_spec[] = { [MPR_FUNCTION_C] = { .output_min = 3355443, .output_max = 13421773 }, }; -struct mpr_chan { - s32 pres; /* pressure value */ - s64 ts; /* timestamp */ -}; - -struct mpr_data { - struct i2c_client *client; - struct mutex lock; /* - * access to device during read - */ - u32 pmin; /* minimal pressure in pascal */ - u32 pmax; /* maximal pressure in pascal */ - enum mpr_func_id function; /* transfer function */ - u32 outmin; /* - * minimal numerical range raw - * value from sensor - */ - u32 outmax; /* - * maximal numerical range raw - * value from sensor - */ - int scale; /* int part of scale */ - int scale2; /* nano part of scale */ - int offset; /* int part of offset */ - int offset2; /* nano part of offset */ - struct gpio_desc *gpiod_reset; /* reset */ - int irq; /* - * end of conversion irq; - * used to distinguish between - * irq mode and reading in a - * loop until data is ready - */ - struct completion completion; /* handshake from irq to read */ - struct mpr_chan chan; /* - * channel values for buffered - * mode - */ -}; - static const struct iio_chan_spec mpr_channels[] = { { .type = IIO_PRESSURE, @@ -152,11 +107,11 @@ static void mpr_reset(struct mpr_data *data) } /** - * mpr_read_pressure() - Read pressure value from sensor via I2C + * mpr_read_pressure() - Read pressure value from sensor * @data: Pointer to private data struct. * @press: Output value read from sensor. * - * Reading from the sensor by sending and receiving I2C telegrams. + * Reading from the sensor by sending and receiving telegrams. * * If there is an end of conversion (EOC) interrupt registered the function * waits for a maximum of one second for the interrupt. @@ -169,25 +124,17 @@ static void mpr_reset(struct mpr_data *data) */ static int mpr_read_pressure(struct mpr_data *data, s32 *press) { - struct device *dev = &data->client->dev; + struct device *dev = data->dev; int ret, i; - u8 wdata[] = {0xAA, 0x00, 0x00}; - s32 status; int nloops = 10; - u8 buf[4]; reinit_completion(&data->completion); - ret = i2c_master_send(data->client, wdata, sizeof(wdata)); + ret = data->ops->write(data, MPR_CMD_SYNC, MPR_PKT_SYNC_LEN); if (ret < 0) { dev_err(dev, "error while writing ret: %d\n", ret); return ret; } - if (ret != sizeof(wdata)) { - dev_err(dev, "received size doesn't fit - ret: %d / %u\n", ret, - (u32)sizeof(wdata)); - return -EIO; - } if (data->irq > 0) { ret = wait_for_completion_timeout(&data->completion, HZ); @@ -205,14 +152,14 @@ static int mpr_read_pressure(struct mpr_data *data, s32 *press) * quite long */ usleep_range(5000, 10000); - status = i2c_smbus_read_byte(data->client); - if (status < 0) { + ret = data->ops->read(data, MPR_CMD_NOP, 1); + if (ret < 0) { dev_err(dev, "error while reading, status: %d\n", - status); - return status; + ret); + return ret; } - if (!(status & MPR_I2C_ERR_FLAG)) + if (!(data->buffer[0] & MPR_ST_ERR_FLAG)) break; } if (i == nloops) { @@ -221,29 +168,19 @@ static int mpr_read_pressure(struct mpr_data *data, s32 *press) } } - ret = i2c_master_recv(data->client, buf, sizeof(buf)); - if (ret < 0) { - dev_err(dev, "error in i2c_master_recv ret: %d\n", ret); + ret = data->ops->read(data, MPR_CMD_NOP, MPR_PKT_NOP_LEN); + if (ret < 0) return ret; - } - if (ret != sizeof(buf)) { - dev_err(dev, "received size doesn't fit - ret: %d / %u\n", ret, - (u32)sizeof(buf)); - return -EIO; - } - if (buf[0] & MPR_I2C_ERR_FLAG) { - /* - * it should never be the case that status still indicates - * business - */ - dev_err(dev, "data still not ready: %08x\n", buf[0]); + if (data->buffer[0] & MPR_ST_ERR_FLAG) { + dev_err(data->dev, + "unexpected status byte %02x\n", data->buffer[0]); return -ETIMEDOUT; } - *press = get_unaligned_be24(&buf[1]); + *press = get_unaligned_be24(&data->buffer[1]); - dev_dbg(dev, "received: %*ph cnt: %d\n", ret, buf, *press); + dev_dbg(dev, "received: %*ph cnt: %d\n", ret, data->buffer, *press); return 0; } @@ -315,26 +252,22 @@ static const struct iio_info mpr_info = { .read_raw = &mpr_read_raw, }; -static int mpr_probe(struct i2c_client *client) +int mpr_common_probe(struct device *dev, const struct mpr_ops *ops, int irq) { int ret; struct mpr_data *data; struct iio_dev *indio_dev; - struct device *dev = &client->dev; s64 scale, offset; u32 func; - if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_READ_BYTE)) - return dev_err_probe(dev, -EOPNOTSUPP, - "I2C functionality not supported\n"); - indio_dev = devm_iio_device_alloc(dev, sizeof(*data)); if (!indio_dev) - return dev_err_probe(dev, -ENOMEM, "couldn't get iio_dev\n"); + return -ENOMEM; data = iio_priv(indio_dev); - data->client = client; - data->irq = client->irq; + data->dev = dev; + data->ops = ops; + data->irq = irq; mutex_init(&data->lock); init_completion(&data->completion); @@ -350,16 +283,10 @@ static int mpr_probe(struct i2c_client *client) return dev_err_probe(dev, ret, "can't get and enable vdd supply\n"); - ret = device_property_read_u32(dev, "honeywell,pmin-pascal", - &data->pmin); + ret = data->ops->init(data->dev); if (ret) - return dev_err_probe(dev, ret, - "honeywell,pmin-pascal could not be read\n"); - ret = device_property_read_u32(dev, "honeywell,pmax-pascal", - &data->pmax); - if (ret) - return dev_err_probe(dev, ret, - "honeywell,pmax-pascal could not be read\n"); + return ret; + ret = device_property_read_u32(dev, "honeywell,transfer-function", &func); if (ret) @@ -371,6 +298,21 @@ static int mpr_probe(struct i2c_client *client) "honeywell,transfer-function %d invalid\n", data->function); + ret = device_property_read_u32(dev, "honeywell,pmin-pascal", + &data->pmin); + if (ret) + return dev_err_probe(dev, ret, + "honeywell,pmin-pascal could not be read\n"); + ret = device_property_read_u32(dev, "honeywell,pmax-pascal", + &data->pmax); + if (ret) + return dev_err_probe(dev, ret, + "honeywell,pmax-pascal could not be read\n"); + + if (data->pmin >= data->pmax) + return dev_err_probe(dev, -EINVAL, + "pressure limits are invalid\n"); + data->outmin = mpr_func_spec[data->function].output_min; data->outmax = mpr_func_spec[data->function].output_max; @@ -389,7 +331,7 @@ static int mpr_probe(struct i2c_client *client) if (data->irq > 0) { ret = devm_request_irq(dev, data->irq, mpr_eoc_handler, IRQF_TRIGGER_RISING, - client->name, + dev_name(dev), data); if (ret) return dev_err_probe(dev, ret, @@ -417,29 +359,8 @@ static int mpr_probe(struct i2c_client *client) return 0; } - -static const struct of_device_id mpr_matches[] = { - { .compatible = "honeywell,mprls0025pa" }, - { } -}; -MODULE_DEVICE_TABLE(of, mpr_matches); - -static const struct i2c_device_id mpr_id[] = { - { "mprls0025pa" }, - { } -}; -MODULE_DEVICE_TABLE(i2c, mpr_id); - -static struct i2c_driver mpr_driver = { - .probe = mpr_probe, - .id_table = mpr_id, - .driver = { - .name = "mprls0025pa", - .of_match_table = mpr_matches, - }, -}; -module_i2c_driver(mpr_driver); +EXPORT_SYMBOL_NS(mpr_common_probe, IIO_HONEYWELL_MPRLS0025PA); MODULE_AUTHOR("Andreas Klinger "); -MODULE_DESCRIPTION("Honeywell MPRLS0025PA I2C driver"); +MODULE_DESCRIPTION("Honeywell MPR pressure sensor core driver"); MODULE_LICENSE("GPL"); diff --git a/drivers/iio/pressure/mprls0025pa.h b/drivers/iio/pressure/mprls0025pa.h new file mode 100644 index 000000000000..9d5c30afa9d6 --- /dev/null +++ b/drivers/iio/pressure/mprls0025pa.h @@ -0,0 +1,102 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * MPRLS0025PA - Honeywell MicroPressure pressure sensor series driver + * + * Copyright (c) Andreas Klinger + * + * Data sheet: + * https://prod-edam.honeywell.com/content/dam/honeywell-edam/sps/siot/en-us/products/sensors/pressure-sensors/board-mount-pressure-sensors/micropressure-mpr-series/documents/sps-siot-mpr-series-datasheet-32332628-ciid-172626.pdf + */ + +#ifndef _MPRLS0025PA_H +#define _MPRLS0025PA_H + +#include +#include +#include +#include +#include +#include + +#include + +#define MPR_MEASUREMENT_RD_SIZE 4 +#define MPR_CMD_NOP 0xf0 +#define MPR_CMD_SYNC 0xaa +#define MPR_PKT_NOP_LEN MPR_MEASUREMENT_RD_SIZE +#define MPR_PKT_SYNC_LEN 3 + +struct device; + +struct iio_chan_spec; +struct iio_dev; + +struct mpr_data; +struct mpr_ops; + +/** + * struct mpr_chan + * @pres: pressure value + * @ts: timestamp + */ +struct mpr_chan { + s32 pres; + s64 ts; +}; + +enum mpr_func_id { + MPR_FUNCTION_A, + MPR_FUNCTION_B, + MPR_FUNCTION_C, +}; + +/** + * struct mpr_data + * @dev: current device structure + * @ops: functions that implement the sensor reads/writes, bus init + * @lock: access to device during read + * @pmin: minimal pressure in pascal + * @pmax: maximal pressure in pascal + * @function: transfer function + * @outmin: minimum raw pressure in counts (based on transfer function) + * @outmax: maximum raw pressure in counts (based on transfer function) + * @scale: pressure scale + * @scale2: pressure scale, decimal number + * @offset: pressure offset + * @offset2: pressure offset, decimal number + * @gpiod_reset: reset + * @irq: end of conversion irq. used to distinguish between irq mode and + * reading in a loop until data is ready + * @completion: handshake from irq to read + * @chan: channel values for buffered mode + * @buffer: raw conversion data + */ +struct mpr_data { + struct device *dev; + const struct mpr_ops *ops; + struct mutex lock; + u32 pmin; + u32 pmax; + enum mpr_func_id function; + u32 outmin; + u32 outmax; + int scale; + int scale2; + int offset; + int offset2; + struct gpio_desc *gpiod_reset; + int irq; + struct completion completion; + struct mpr_chan chan; + u8 buffer[MPR_MEASUREMENT_RD_SIZE] __aligned(IIO_DMA_MINALIGN); +}; + +struct mpr_ops { + int (*init)(struct device *dev); + int (*read)(struct mpr_data *data, const u8 cmd, const u8 cnt); + int (*write)(struct mpr_data *data, const u8 cmd, const u8 cnt); +}; + +int mpr_common_probe(struct device *dev, const struct mpr_ops *ops, int irq); + +#endif diff --git a/drivers/iio/pressure/mprls0025pa_i2c.c b/drivers/iio/pressure/mprls0025pa_i2c.c new file mode 100644 index 000000000000..7e9d1617c9f3 --- /dev/null +++ b/drivers/iio/pressure/mprls0025pa_i2c.c @@ -0,0 +1,98 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * MPRLS0025PA - Honeywell MicroPressure pressure sensor series driver + * + * Copyright (c) Andreas Klinger + * + * Data sheet: + * https://prod-edam.honeywell.com/content/dam/honeywell-edam/sps/siot/en-us/products/sensors/pressure-sensors/board-mount-pressure-sensors/micropressure-mpr-series/documents/sps-siot-mpr-series-datasheet-32332628-ciid-172626.pdf + */ + +#include +#include +#include +#include + +#include "mprls0025pa.h" + +static int mpr_i2c_init(struct device *unused) +{ + return 0; +} + +static int mpr_i2c_read(struct mpr_data *data, const u8 unused, const u8 cnt) +{ + int ret; + struct i2c_client *client = to_i2c_client(data->dev); + + if (cnt > MPR_MEASUREMENT_RD_SIZE) + return -EOVERFLOW; + + memset(data->buffer, 0, MPR_MEASUREMENT_RD_SIZE); + ret = i2c_master_recv(client, data->buffer, cnt); + if (ret < 0) + return ret; + else if (ret != cnt) + return -EIO; + + return 0; +} + +static int mpr_i2c_write(struct mpr_data *data, const u8 cmd, const u8 unused) +{ + int ret; + struct i2c_client *client = to_i2c_client(data->dev); + u8 wdata[MPR_PKT_SYNC_LEN]; + + memset(wdata, 0, sizeof(wdata)); + wdata[0] = cmd; + + ret = i2c_master_send(client, wdata, MPR_PKT_SYNC_LEN); + if (ret < 0) + return ret; + else if (ret != MPR_PKT_SYNC_LEN) + return -EIO; + + return 0; +} + +static const struct mpr_ops mpr_i2c_ops = { + .init = mpr_i2c_init, + .read = mpr_i2c_read, + .write = mpr_i2c_write, +}; + +static int mpr_i2c_probe(struct i2c_client *client) +{ + if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_READ_BYTE)) + return -EOPNOTSUPP; + + return mpr_common_probe(&client->dev, &mpr_i2c_ops, client->irq); +} + +static const struct of_device_id mpr_i2c_match[] = { + { .compatible = "honeywell,mprls0025pa" }, + {} +}; +MODULE_DEVICE_TABLE(of, mpr_i2c_match); + +static const struct i2c_device_id mpr_i2c_id[] = { + { "mprls0025pa" }, + {} +}; +MODULE_DEVICE_TABLE(i2c, mpr_i2c_id); + +static struct i2c_driver mpr_i2c_driver = { + .probe = mpr_i2c_probe, + .id_table = mpr_i2c_id, + .driver = { + .name = "mprls0025pa", + .of_match_table = mpr_i2c_match, + }, +}; +module_i2c_driver(mpr_i2c_driver); + +MODULE_AUTHOR("Andreas Klinger "); +MODULE_DESCRIPTION("Honeywell MPR pressure sensor i2c driver"); +MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(IIO_HONEYWELL_MPRLS0025PA); From patchwork Fri Dec 29 09:24:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petre Rodan X-Patchwork-Id: 183886 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp2467126dyb; Fri, 29 Dec 2023 01:29:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IF65QqFCOlEnXQeqJO4Aqvyo2mfeH1ms/t+ZK3N5NMO02skpRK5fNZyrMr5znYnKl83QzKV X-Received: by 2002:a05:6a20:6a1c:b0:196:8ad0:9a11 with SMTP id p28-20020a056a206a1c00b001968ad09a11mr408282pzk.96.1703842184380; Fri, 29 Dec 2023 01:29:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703842184; cv=none; d=google.com; s=arc-20160816; b=SVk/7nr0E5xvqGlAU7zfNzIF6x2PJBkn0j3Laf4iyiiaixxU6gOjuRfqhT0pLThH6T avNAotXtqaTIuBybm6ZFyYiBHWo2xaCHPwYHEQ64saVehaF7RcMMTQ/rSHi3rAFEC4oY 1l51re1lyjTe9kTTvYLDniNgk5GhzJE1cBLGszBZqYYDokY6IA1R4sweNpxnMWPchCI1 HOBzIUAagdgtW7lpVGwniB2NLRxTyY6PnjAOfVFGtxldHm5suKLp0kuKAdb1KYsVm7ym zGzisbsfWsqYSb8ijhLMzR5QG9ykBC4UeAVfZOxkVqGJkJLBgxXjx1F009usKlFomT/+ soEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=wBV4G59f63IxLXNtNuvxtsOzy6z5ztAXBgYdHlfhyEE=; fh=cuSrpdmFbNnIGKLvcD6905UtzyKVEbJe+tTFY3eiseU=; b=MIzo7gCBTERxVwvJg5JoC8lyc263WxwRYXxIWRWgmJo9RVzHykm2wwEscUyQSw9/VG 6CCr1LpbaabPNJqT2hmWcezAHkuusLyiz7fkbyekW0kguAAFoMxuHSSD+eDj52Xk/4we Lqkc8A6Qe4VeOM1XrFrVd7rf4rK5cEquUKdu5TKmWJgHw9jePUOTErKjj+HNn8sA1DQe uTeExRsR1jqn+CdUu3QmOnYFQ56HnNlYgVz9vMVS7Uih+sW45JJv4B6ZgbwTCChm6M+t MoYsn5fd/nW/dcqWwuWlfHILY/uHpo2EbArguVNTkkHSxu6KGP07lT4qKSguA6xDG+DP EtNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@subdimension.ro header.s=skycaves header.b=jVcZo+Kq; spf=pass (google.com: domain of linux-kernel+bounces-13035-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13035-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=subdimension.ro Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id m15-20020a17090ab78f00b0028be0f58967si14374815pjr.96.2023.12.29.01.29.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Dec 2023 01:29:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-13035-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@subdimension.ro header.s=skycaves header.b=jVcZo+Kq; spf=pass (google.com: domain of linux-kernel+bounces-13035-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13035-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=subdimension.ro Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 48BFAB22E59 for ; Fri, 29 Dec 2023 09:27:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2F651134D7; Fri, 29 Dec 2023 09:25:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=subdimension.ro header.i=@subdimension.ro header.b="jVcZo+Kq" X-Original-To: linux-kernel@vger.kernel.org Received: from mail.subdimension.ro (skycaves.subdimension.ro [172.104.132.142]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 36E2811736; Fri, 29 Dec 2023 09:25:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=subdimension.ro Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=subdimension.ro Received: from localhost.localdomain (unknown [188.24.94.216]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mail.subdimension.ro (Postfix) with ESMTPSA id BB45A28B596; Fri, 29 Dec 2023 09:25:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=subdimension.ro; s=skycaves; t=1703841909; bh=akQy0eNST9HQO0Ptl17uHVfMO9+tHIXtxlAzCJyC6XA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=jVcZo+KqlVWn4jUf1spWjrk4er3QmBucmlqknHhIaONBIFQHrbOnmZ2wf45mGvXrV +inYKmz+DsCGtryl1liB3MxbryGg/7I7OFhax+u4hNev7ygpjz2S6A8ITP93w7OZfu DraSC1ZwPVloqutACRzq+w53XmSVqli8sg6QkP/k= From: Petre Rodan To: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Petre Rodan , Andreas Klinger , Jonathan Cameron , Lars-Peter Clausen , Andy Shevchenko , Angel Iglesias , Matti Vaittinen Subject: [PATCH v3 09/10] iio: pressure: mprls0025pa add triplet property Date: Fri, 29 Dec 2023 11:24:37 +0200 Message-ID: <20231229092445.30180-10-petre.rodan@subdimension.ro> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231229092445.30180-1-petre.rodan@subdimension.ro> References: <20231229092445.30180-1-petre.rodan@subdimension.ro> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786608022523518951 X-GMAIL-MSGID: 1786608022523518951 Add honeywell,pressure-triplet property that automatically initializes pmin-pascal, pmax-pascal so that the user is not required to look-up the chip in the datasheet and convert various units to pascals himself. Co-developed-by: Andreas Klinger Signed-off-by: Andreas Klinger Signed-off-by: Petre Rodan --- v2 -> v3 no changes drivers/iio/pressure/mprls0025pa.c | 105 ++++++++++++++++++++++++++--- 1 file changed, 97 insertions(+), 8 deletions(-) -- 2.41.0 diff --git a/drivers/iio/pressure/mprls0025pa.c b/drivers/iio/pressure/mprls0025pa.c index ce20cf362fac..33a15d4c642c 100644 --- a/drivers/iio/pressure/mprls0025pa.c +++ b/drivers/iio/pressure/mprls0025pa.c @@ -80,6 +80,78 @@ static const struct mpr_func_spec mpr_func_spec[] = { [MPR_FUNCTION_C] = { .output_min = 3355443, .output_max = 13421773 }, }; +enum mpr_variants { + MPR0001BA = 0x00, MPR01_6BA = 0x01, MPR02_5BA = 0x02, MPR0060MG = 0x03, + MPR0100MG = 0x04, MPR0160MG = 0x05, MPR0250MG = 0x06, MPR0400MG = 0x07, + MPR0600MG = 0x08, MPR0001BG = 0x09, MPR01_6BG = 0x0a, MPR02_5BG = 0x0b, + MPR0100KA = 0x0c, MPR0160KA = 0x0d, MPR0250KA = 0x0e, MPR0006KG = 0x0f, + MPR0010KG = 0x10, MPR0016KG = 0x11, MPR0025KG = 0x12, MPR0040KG = 0x13, + MPR0060KG = 0x14, MPR0100KG = 0x15, MPR0160KG = 0x16, MPR0250KG = 0x17, + MPR0015PA = 0x18, MPR0025PA = 0x19, MPR0030PA = 0x1a, MPR0001PG = 0x1b, + MPR0005PG = 0x1c, MPR0015PG = 0x1d, MPR0030PG = 0x1e, MPR0300YG = 0x1f, + MPR_VARIANTS_MAX +}; + +static const char * const mpr_triplet_variants[MPR_VARIANTS_MAX] = { + [MPR0001BA] = "0001BA", [MPR01_6BA] = "01.6BA", [MPR02_5BA] = "02.5BA", + [MPR0060MG] = "0060MG", [MPR0100MG] = "0100MG", [MPR0160MG] = "0160MG", + [MPR0250MG] = "0250MG", [MPR0400MG] = "0400MG", [MPR0600MG] = "0600MG", + [MPR0001BG] = "0001BG", [MPR01_6BG] = "01.6BG", [MPR02_5BG] = "02.5BG", + [MPR0100KA] = "0100KA", [MPR0160KA] = "0160KA", [MPR0250KA] = "0250KA", + [MPR0006KG] = "0006KG", [MPR0010KG] = "0010KG", [MPR0016KG] = "0016KG", + [MPR0025KG] = "0025KG", [MPR0040KG] = "0040KG", [MPR0060KG] = "0060KG", + [MPR0100KG] = "0100KG", [MPR0160KG] = "0160KG", [MPR0250KG] = "0250KG", + [MPR0015PA] = "0015PA", [MPR0025PA] = "0025PA", [MPR0030PA] = "0030PA", + [MPR0001PG] = "0001PG", [MPR0005PG] = "0005PG", [MPR0015PG] = "0015PG", + [MPR0030PG] = "0030PG", [MPR0300YG] = "0300YG" +}; + +/** + * struct mpr_range_config - list of pressure ranges based on nomenclature + * @pmin: lowest pressure that can be measured + * @pmax: highest pressure that can be measured + */ +struct mpr_range_config { + const s32 pmin; + const s32 pmax; +}; + +/* All min max limits have been converted to pascals */ +static const struct mpr_range_config mpr_range_config[MPR_VARIANTS_MAX] = { + [MPR0001BA] = { .pmin = 0, .pmax = 100000 }, + [MPR01_6BA] = { .pmin = 0, .pmax = 160000 }, + [MPR02_5BA] = { .pmin = 0, .pmax = 250000 }, + [MPR0060MG] = { .pmin = 0, .pmax = 6000 }, + [MPR0100MG] = { .pmin = 0, .pmax = 10000 }, + [MPR0160MG] = { .pmin = 0, .pmax = 16000 }, + [MPR0250MG] = { .pmin = 0, .pmax = 25000 }, + [MPR0400MG] = { .pmin = 0, .pmax = 40000 }, + [MPR0600MG] = { .pmin = 0, .pmax = 60000 }, + [MPR0001BG] = { .pmin = 0, .pmax = 100000 }, + [MPR01_6BG] = { .pmin = 0, .pmax = 160000 }, + [MPR02_5BG] = { .pmin = 0, .pmax = 250000 }, + [MPR0100KA] = { .pmin = 0, .pmax = 100000 }, + [MPR0160KA] = { .pmin = 0, .pmax = 160000 }, + [MPR0250KA] = { .pmin = 0, .pmax = 250000 }, + [MPR0006KG] = { .pmin = 0, .pmax = 6000 }, + [MPR0010KG] = { .pmin = 0, .pmax = 10000 }, + [MPR0016KG] = { .pmin = 0, .pmax = 16000 }, + [MPR0025KG] = { .pmin = 0, .pmax = 25000 }, + [MPR0040KG] = { .pmin = 0, .pmax = 40000 }, + [MPR0060KG] = { .pmin = 0, .pmax = 60000 }, + [MPR0100KG] = { .pmin = 0, .pmax = 100000 }, + [MPR0160KG] = { .pmin = 0, .pmax = 160000 }, + [MPR0250KG] = { .pmin = 0, .pmax = 250000 }, + [MPR0015PA] = { .pmin = 0, .pmax = 103421 }, + [MPR0025PA] = { .pmin = 0, .pmax = 172369 }, + [MPR0030PA] = { .pmin = 0, .pmax = 206843 }, + [MPR0001PG] = { .pmin = 0, .pmax = 6895 }, + [MPR0005PG] = { .pmin = 0, .pmax = 34474 }, + [MPR0015PG] = { .pmin = 0, .pmax = 103421 }, + [MPR0030PG] = { .pmin = 0, .pmax = 206843 }, + [MPR0300YG] = { .pmin = 0, .pmax = 39997 } +}; + static const struct iio_chan_spec mpr_channels[] = { { .type = IIO_PRESSURE, @@ -257,6 +329,7 @@ int mpr_common_probe(struct device *dev, const struct mpr_ops *ops, int irq) int ret; struct mpr_data *data; struct iio_dev *indio_dev; + const char *triplet; s64 scale, offset; u32 func; @@ -298,16 +371,32 @@ int mpr_common_probe(struct device *dev, const struct mpr_ops *ops, int irq) "honeywell,transfer-function %d invalid\n", data->function); - ret = device_property_read_u32(dev, "honeywell,pmin-pascal", - &data->pmin); - if (ret) - return dev_err_probe(dev, ret, + ret = device_property_read_string(dev, "honeywell,pressure-triplet", + &triplet); + if (ret) { + ret = device_property_read_u32(dev, "honeywell,pmin-pascal", + &data->pmin); + if (ret) + return dev_err_probe(dev, ret, "honeywell,pmin-pascal could not be read\n"); - ret = device_property_read_u32(dev, "honeywell,pmax-pascal", - &data->pmax); - if (ret) - return dev_err_probe(dev, ret, + + ret = device_property_read_u32(dev, "honeywell,pmax-pascal", + &data->pmax); + if (ret) + return dev_err_probe(dev, ret, "honeywell,pmax-pascal could not be read\n"); + } else { + ret = device_property_match_property_string(dev, + "honeywell,pressure-triplet", + mpr_triplet_variants, + MPR_VARIANTS_MAX); + if (ret < 0) + return dev_err_probe(dev, -EINVAL, + "honeywell,pressure-triplet is invalid\n"); + + data->pmin = mpr_range_config[ret].pmin; + data->pmax = mpr_range_config[ret].pmax; + } if (data->pmin >= data->pmax) return dev_err_probe(dev, -EINVAL, From patchwork Fri Dec 29 09:24:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petre Rodan X-Patchwork-Id: 183884 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp2466561dyb; Fri, 29 Dec 2023 01:27:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IF+kFuJNuFJttXUIOmqQDOUWVricb52fJOCahu0tnnwYnWXynczuJEKiO716yjAyGG/yGHJ X-Received: by 2002:aa7:880c:0:b0:6d9:bd28:687 with SMTP id c12-20020aa7880c000000b006d9bd280687mr3574443pfo.40.1703842074947; Fri, 29 Dec 2023 01:27:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703842074; cv=none; d=google.com; s=arc-20160816; b=jT3KVRJ2JvVQswtQ024dyxjAA0CaHSuOAyqf6hpSSsJCYPHRSAot9Jb+UEB9HhbeQz qi+YGzWjHtIJko5P9wio+sa/e1un36W8qzukFlnbZAngLN/ftv8pLz3CXxlqXw49dD2w pATWrE5xyMl6qPgWYLHQQVSEm+6FOHVAPCOSwV1rL+5uz+x06TGsFh1nWAKeAHVNvu1t H/SdS+AiIFIA2uwa5RzsvO1cAfZSDMiwvmhM9B9WhrKw/BPeJx/Eeal49NdwFanFGbL5 PhvZZkjST3kLpCbJP0tSh3Vrq4M3OFPHesjgBpaNc0liRGV4YAcmxs0no4gIc9eJJCtH ZM6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=0tVaWL5YVxbtZzQki8xraSwaPOuutOW84Tnj9JdwmF4=; fh=cuSrpdmFbNnIGKLvcD6905UtzyKVEbJe+tTFY3eiseU=; b=F2BHwiaA/rTTK+f+9Cj6RjLfz/X/x/j0zZa/Lh0vcX1Czy6VDz90tbklFsc7A0RZ7q zzlcuBfCb65ay0/3n69e9FFUXQz2zicYBl9UIITVufe5pVOwedQ1LKoNjj2iKaJXxYKL TGPyTsyoB0rPfo4GTQl+XF5Ol+pEpJcxAhi1pGHNO8rbqVouSXj+c3KZpmeLlP42JLcD u9+idxdfyfoWx3U3+nwWJQmSVYnOYyUXEb0kDnYdp6vHofpoBkRk5pbHYHLhSBjedoV0 ca79gob5Oaq149pH4OOIHzmrjdRbSRExNSwuW62GCcRMXgyPrUNwjwuQ2GrUWzN8xxt9 IPIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@subdimension.ro header.s=skycaves header.b="UkNGK/Zw"; spf=pass (google.com: domain of linux-kernel+bounces-13036-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13036-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=subdimension.ro Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id v20-20020a63f854000000b005ce014d78a3si10835714pgj.366.2023.12.29.01.27.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Dec 2023 01:27:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-13036-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@subdimension.ro header.s=skycaves header.b="UkNGK/Zw"; spf=pass (google.com: domain of linux-kernel+bounces-13036-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13036-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=subdimension.ro Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id B0A0928458A for ; Fri, 29 Dec 2023 09:27:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 692D313AD1; Fri, 29 Dec 2023 09:25:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=subdimension.ro header.i=@subdimension.ro header.b="UkNGK/Zw" X-Original-To: linux-kernel@vger.kernel.org Received: from mail.subdimension.ro (skycaves.subdimension.ro [172.104.132.142]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AFE58125B2; Fri, 29 Dec 2023 09:25:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=subdimension.ro Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=subdimension.ro Received: from localhost.localdomain (unknown [188.24.94.216]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mail.subdimension.ro (Postfix) with ESMTPSA id 1BB1928B597; Fri, 29 Dec 2023 09:25:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=subdimension.ro; s=skycaves; t=1703841909; bh=eKbNnj7orFcc/inNQ34FTt139oscjUlCdr8IE4HhtlA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=UkNGK/ZwExSm4NC5CgKSJSfwHYZVzwW0GL2w9wfyBiRNPgV8vTO8daIbMzMrp9ffk KpFhgg+qAL1l6svxEscx6OnDXPQ2gMQIg5fYooZ2hdxY0x/3S7C5BfNyiwMkg/WwJP Y+dPL7Aw0gUmSnIK6WvR3O/e8addRp2S9Y6I+r1U= From: Petre Rodan To: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Petre Rodan , Andreas Klinger , Jonathan Cameron , Lars-Peter Clausen , Andy Shevchenko , Angel Iglesias , Matti Vaittinen Subject: [PATCH v3 10/10] iio: pressure: mprls0025pa add SPI driver Date: Fri, 29 Dec 2023 11:24:38 +0200 Message-ID: <20231229092445.30180-11-petre.rodan@subdimension.ro> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231229092445.30180-1-petre.rodan@subdimension.ro> References: <20231229092445.30180-1-petre.rodan@subdimension.ro> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786607907261057750 X-GMAIL-MSGID: 1786607907261057750 Add SPI component of the driver. Tested with mprls0015pa0000sa in spi mode on BeagleBone Black on slightly patched 6.7.0-rc6 mainline. Tested with mprls0025pa in i2c mode on BeagleBone Black with togreg branch on git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git (tag: iio-for-6.8a) Tested-by: Andreas Klinger Signed-off-by: Petre Rodan --- v2 -> v3 removed iio.h include line drivers/iio/pressure/Kconfig | 8 ++- drivers/iio/pressure/Makefile | 1 + drivers/iio/pressure/mprls0025pa_spi.c | 89 ++++++++++++++++++++++++++ 3 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 drivers/iio/pressure/mprls0025pa_spi.c -- 2.41.0 diff --git a/drivers/iio/pressure/Kconfig b/drivers/iio/pressure/Kconfig index f03007cfec85..5da7931dc537 100644 --- a/drivers/iio/pressure/Kconfig +++ b/drivers/iio/pressure/Kconfig @@ -181,8 +181,9 @@ config MPL3115 config MPRLS0025PA tristate "Honeywell MPRLS0025PA (MicroPressure sensors series)" - depends on I2C + depends on (I2C || SPI_MASTER) select MPRLS0025PA_I2C if I2C + select MPRLS0025PA_SPI if SPI_MASTER select IIO_BUFFER select IIO_TRIGGERED_BUFFER help @@ -198,6 +199,11 @@ config MPRLS0025PA_I2C depends on MPRLS0025PA depends on I2C +config MPRLS0025PA_SPI + tristate + depends on MPRLS0025PA + depends on SPI_MASTER + config MS5611 tristate "Measurement Specialties MS5611 pressure sensor driver" select IIO_BUFFER diff --git a/drivers/iio/pressure/Makefile b/drivers/iio/pressure/Makefile index 7754135e190c..a93709e35760 100644 --- a/drivers/iio/pressure/Makefile +++ b/drivers/iio/pressure/Makefile @@ -25,6 +25,7 @@ obj-$(CONFIG_MPL115_SPI) += mpl115_spi.o obj-$(CONFIG_MPL3115) += mpl3115.o obj-$(CONFIG_MPRLS0025PA) += mprls0025pa.o obj-$(CONFIG_MPRLS0025PA_I2C) += mprls0025pa_i2c.o +obj-$(CONFIG_MPRLS0025PA_SPI) += mprls0025pa_spi.o obj-$(CONFIG_MS5611) += ms5611_core.o obj-$(CONFIG_MS5611_I2C) += ms5611_i2c.o obj-$(CONFIG_MS5611_SPI) += ms5611_spi.o diff --git a/drivers/iio/pressure/mprls0025pa_spi.c b/drivers/iio/pressure/mprls0025pa_spi.c new file mode 100644 index 000000000000..32f6c2e60380 --- /dev/null +++ b/drivers/iio/pressure/mprls0025pa_spi.c @@ -0,0 +1,89 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * MPRLS0025PA - Honeywell MicroPressure MPR series SPI sensor driver + * + * Copyright (c) 2024 Petre Rodan + * + * Data sheet: + * https://prod-edam.honeywell.com/content/dam/honeywell-edam/sps/siot/en-us/products/sensors/pressure-sensors/board-mount-pressure-sensors/micropressure-mpr-series/documents/sps-siot-mpr-series-datasheet-32332628-ciid-172626.pdf + */ + +#include +#include +#include +#include + +#include "mprls0025pa.h" + +struct mpr_spi_buf { + u8 tx[MPR_MEASUREMENT_RD_SIZE] __aligned(IIO_DMA_MINALIGN); +}; + +static int mpr_spi_init(struct device *dev) +{ + struct spi_device *spi = to_spi_device(dev); + struct mpr_spi_buf *buf; + + buf = devm_kzalloc(dev, sizeof(*buf), GFP_KERNEL); + if (!buf) + return -ENOMEM; + + spi_set_drvdata(spi, buf); + + return 0; +} + +static int mpr_spi_xfer(struct mpr_data *data, const u8 cmd, const u8 pkt_len) +{ + struct spi_device *spi = to_spi_device(data->dev); + struct mpr_spi_buf *buf = spi_get_drvdata(spi); + struct spi_transfer xfer; + + if (pkt_len > MPR_MEASUREMENT_RD_SIZE) + return -EOVERFLOW; + + buf->tx[0] = cmd; + xfer.tx_buf = buf->tx; + xfer.rx_buf = data->buffer; + xfer.len = pkt_len; + + return spi_sync_transfer(spi, &xfer, 1); +} + +static const struct mpr_ops mpr_spi_ops = { + .init = mpr_spi_init, + .read = mpr_spi_xfer, + .write = mpr_spi_xfer, +}; + +static int mpr_spi_probe(struct spi_device *spi) +{ + return mpr_common_probe(&spi->dev, &mpr_spi_ops, spi->irq); +} + +static const struct of_device_id mpr_spi_match[] = { + { .compatible = "honeywell,mprls0025pa" }, + {} +}; +MODULE_DEVICE_TABLE(of, mpr_spi_match); + +static const struct spi_device_id mpr_spi_id[] = { + { "mprls0025pa" }, + {} +}; +MODULE_DEVICE_TABLE(spi, mpr_spi_id); + +static struct spi_driver mpr_spi_driver = { + .driver = { + .name = "mprls0025pa", + .of_match_table = mpr_spi_match, + }, + .probe = mpr_spi_probe, + .id_table = mpr_spi_id, +}; +module_spi_driver(mpr_spi_driver); + +MODULE_AUTHOR("Petre Rodan "); +MODULE_DESCRIPTION("Honeywell MPR pressure sensor spi driver"); +MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(IIO_HONEYWELL_MPRLS0025PA);