From patchwork Sun Dec 24 14:34:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petre Rodan X-Patchwork-Id: 183058 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp2160900dyi; Sun, 24 Dec 2023 06:36:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IGmmCDovxtKV/hr1+an3r1iSwpijEdn0+2AjX7+eu+7S/6WQy9d88GZ3sexiA/waDUAQ1nI X-Received: by 2002:a50:935c:0:b0:553:aa33:7876 with SMTP id n28-20020a50935c000000b00553aa337876mr1920820eda.31.1703428565107; Sun, 24 Dec 2023 06:36:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703428565; cv=none; d=google.com; s=arc-20160816; b=CpCCKgOZAykOZWaQ69KZZXy3byeME6EdV3fdvgFLJdDExghZ73erNk822yg9YbM8m7 0UHQswhlGpZRgBITTWyOeQJrbEYIw7mBnDyzeRRkaXFUTedSxs3cFm3jPi+GyoWSC8tC XkWfGexBpCecrSRcoaACRNMs/9W9YyUzuBiFo+BvU84yky/N48lgI26G2XDgyrrCitFE grw0swDQxbA+4EtLK90/nj7UiOVsJlcbMcM5ehqzrj/bJf5PcpwErQ+jNY3dNOQumvDN NMVliu3/y83qgMzVXSUlLl3m9MletVAwoT78DSz9a495ezhM8LcuG5Ef557rnzysEuDS QR4Q== 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=oRMlm6Cc/X8+3TT6FqWc16ulv+fw9P/DKSN7M0Wvchc=; fh=A3NghPjUcaYWJrBEcBDmjinT5n8U7kPeBkd9SVrhfnk=; b=UqC6YG1CXrm9EqB6F2sZZc7IvUWNMEYQybOhZ1WGp8Jvv6y6TS+i9cdAYJNjeEUAxi xWLgJga+a/ScH9qpqCAuNcyHGzDxE2TQL6RrdVG3BJiOyPNCbv14X3mGxM6LIpsY6/EN cusveOjdMOifaaB+VyOj+MTpckPnMQA0HUO0ASPlzXhyn+EPj8wknCKlq109yVObO53n qiyWesiUCyf0qGVRNRVLWmejNj0RGR9Y3TBWZLmJDlnrf8KKwajbV+DXcJxPdkFBWGHP BTTzttKq8LpsCDUIJWOGFhDi4tLKTShC4ldVuB13DanAENDbaR7sH5xN9pAc/JTYgM2d IdFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@subdimension.ro header.s=skycaves header.b=kSM00V4u; spf=pass (google.com: domain of linux-kernel+bounces-10721-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10721-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. [147.75.80.249]) by mx.google.com with ESMTPS id g4-20020a1709064e4400b00a1dcf3d7806si3645245ejw.287.2023.12.24.06.36.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Dec 2023 06:36:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-10721-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@subdimension.ro header.s=skycaves header.b=kSM00V4u; spf=pass (google.com: domain of linux-kernel+bounces-10721-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10721-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 B89931F20C28 for ; Sun, 24 Dec 2023 14:36:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F317FD30F; Sun, 24 Dec 2023 14:35:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=subdimension.ro header.i=@subdimension.ro header.b="kSM00V4u" 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 EADB715D0; Sun, 24 Dec 2023 14:35:17 +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 E016228B538; Sun, 24 Dec 2023 14:35:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=subdimension.ro; s=skycaves; t=1703428510; bh=gnzCEEr9FE5S/35WvgRN9WGB3sJnxOb4JQsoYP6j3nM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=kSM00V4uakA2eSqATirN/KIGEm+h4F2zSk1Vf30fp+yZBeggqZ9oSy+VveDKh6LH5 PCrfCB5sGH9P/38gel27e6nbBolpDqbLiEZ62H9X0OKrY3mJng17GJvObeYIGHPHyp veEb+EltaNU4Tm9UqbbxUq6eI7Vwav1Cj6eu553Q= From: Petre Rodan To: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Petre Rodan , Andreas Klinger , Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley Subject: [PATCH v2 01/10] dt-bindings: iio: pressure: honeywell,mprls0025pa.yaml fix Date: Sun, 24 Dec 2023 16:34:46 +0200 Message-ID: <20231224143500.10940-2-petre.rodan@subdimension.ro> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231224143500.10940-1-petre.rodan@subdimension.ro> References: <20231224143500.10940-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: 1786174311048256007 X-GMAIL-MSGID: 1786174311048256007 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. Signed-off-by: Petre Rodan Signed-off-by: Andreas Klinger Acked-by: Krzysztof Kozlowski --- .../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 Sun Dec 24 14:34:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petre Rodan X-Patchwork-Id: 183059 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp2161060dyi; Sun, 24 Dec 2023 06:36:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IEC4in85jwXEpvuC3amyLmYAr9jL/pQHkMy2NCmjS/kjzlVT/6TIOe9wI4swO/MQKaxFg6j X-Received: by 2002:a05:6214:b62:b0:67a:c46c:64e1 with SMTP id ey2-20020a0562140b6200b0067ac46c64e1mr6596949qvb.8.1703428584037; Sun, 24 Dec 2023 06:36:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703428584; cv=none; d=google.com; s=arc-20160816; b=BmrPB/VNZwlkTFSIGeDL0h9WqtSZjLAbALJ0XA3wlN787WG9SH2IYDIxofKzewyxPJ VvBwYbL2h6z9jtzvfPl/0txQEap/BXADxuNCP6d5+xo6I9Zal1Of5Khz6q1PRT/B+oNY UN1/TwBy+CoNTi89OVYuRLqXvS7pM4/y8UZkjIZkQ95orUMLWTunqI2m3DQVIuG7oZiA rX7+Zn+//jaU0LWlJ7TEjBR3ecKpgwcD9LB+mq2zdjyeu85OxoAiDK9NvY2MtLUlzrVi pA6xDwa4DGsS2AAXBwriFXt5X60Isexmc0+cKQiekPWA6AEsiU1tmCW4pZ0KHVKz1LMy 9Dsw== 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=KKVGIpWXip1QK6iYCkU+gL5WRrEWg8vqcSywOc/WI/U=; fh=A3NghPjUcaYWJrBEcBDmjinT5n8U7kPeBkd9SVrhfnk=; b=djoB7O7N+1JLXEGsLWVgOhCWoeOTjmSE5SPs9Y5iLf8L1qDq0ccJ7m4TAUCn/oR98p z/rF9vtvsoOJKuzKxzvX569UKfB/WhbJLYKTDp9A8zU6bfMIDsSY2Riq7svdgGs7Ywlh xqgXzzqempVYq0/0Sf0ODC7zonf4tdmMk9uIM8HE3Fx1/j4LFFMfBhLNSTewD2pKnHkJ Y2LFugJWFeC/K9Y68G3VxEjUuhq3H86mfRqJ8+xv8NBLQ75dYziyNC5OWRKDO5stH9TJ hD9uhoYJ9vmiUrXpa9bT4pwTwEzXT9FnGs0hKvKW1oEQ5epDCKv1n+HmAOTqjmzdwLhl Ifyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@subdimension.ro header.s=skycaves header.b=BNJ0qFZP; spf=pass (google.com: domain of linux-kernel+bounces-10723-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10723-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. [147.75.199.223]) by mx.google.com with ESMTPS id 2-20020a05620a048200b007811adc94e6si8445386qkr.142.2023.12.24.06.36.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Dec 2023 06:36:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-10723-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@subdimension.ro header.s=skycaves header.b=BNJ0qFZP; spf=pass (google.com: domain of linux-kernel+bounces-10723-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10723-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 CECB61C20A27 for ; Sun, 24 Dec 2023 14:36:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BCB69EAD9; Sun, 24 Dec 2023 14:35:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=subdimension.ro header.i=@subdimension.ro header.b="BNJ0qFZP" 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 9EBE623CD; Sun, 24 Dec 2023 14:35: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 3C69C28B539; Sun, 24 Dec 2023 14:35:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=subdimension.ro; s=skycaves; t=1703428510; bh=CeojQm5YJLUA6vqpb0TQgDQe551dZqsj31EWZZIFRqQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=BNJ0qFZPipoL+gkre9Ih6basEQVqF+3PMwoktIVC/lQDcnGGDISLFMmD83y21jMyA Y4hhVxFg5J2EAHHkFZ//6G3Yg5OpjN2nvcLllxP2PfA6cyiZSIGs0V5WWheMsu4y46 0QeqI314RkB+Du+FXh9FIGLIUvFFXFljdLFHcnWE= From: Petre Rodan To: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Petre Rodan , Andreas Klinger , Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley Subject: [PATCH v2 02/10] dt-bindings: iio: pressure: honeywell,mprls0025pa.yaml add pressure-triplet Date: Sun, 24 Dec 2023 16:34:47 +0200 Message-ID: <20231224143500.10940-3-petre.rodan@subdimension.ro> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231224143500.10940-1-petre.rodan@subdimension.ro> References: <20231224143500.10940-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: 1786174331118136885 X-GMAIL-MSGID: 1786174331118136885 Change order of properties in order for the end user to de-prioritize 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. Signed-off-by: Petre Rodan Signed-off-by: Andreas Klinger --- .../iio/pressure/honeywell,mprls0025pa.yaml | 64 ++++++++++++++----- 1 file changed, 47 insertions(+), 17 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..e4021306d187 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 + To support different models one need to specify its pressure triplet as well + as the transfer function. + + For custom models the pressure values can alternatively be specified manually. + The minimal range value stands for the minimum pressure and the maximum value + also for the maximum pressure with linear relation inside the range. + Pressure range needs to be converted from the datasheet specified unit to pascal. 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,52 @@ 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. + To be specified only if honeywell,pressure-triplet is not set. + + honeywell,pmax-pascal: + description: + Maximum pressure value the sensor can measure in pascal. + To be specified only if honeywell,pressure-triplet is not set. + 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,pmin-pascal + - honeywell,pmax-pascal + - required: + - honeywell,pressure-triplet + +allOf: + - if: + required: + - honeywell,pressure-triplet + then: + properties: + honeywell,pmin-pascal: false + honeywell,pmax-pascal: false + additionalProperties: false examples: @@ -99,8 +129,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 Sun Dec 24 14:34:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petre Rodan X-Patchwork-Id: 183061 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp2161527dyi; Sun, 24 Dec 2023 06:37:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IHQ/N7wku/He0DC5Eb2zZgtYjDDyrS6SYl1i7plDRz8nbCJFk2iUtZw0W2pmTu76mZx3pv/ X-Received: by 2002:a05:6a21:33a7:b0:195:41d9:1829 with SMTP id yy39-20020a056a2133a700b0019541d91829mr4798359pzb.106.1703428656388; Sun, 24 Dec 2023 06:37:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703428656; cv=none; d=google.com; s=arc-20160816; b=wN16wSCSoqO+QkNIjvQyDbx9iFAyd4+oPvXAYmLWYtb6v4py6Bi7kdvPKw0moEzO7b h+MmI9k3YZFdnYN28xzH74fXsKQ90MGFsdv+vq2/9Pg8Vdtw8V9Ax2JYk2Tf/BB5N0bD 9jItPxmBlfATU9U9wN7JhljnB5kyYde1vzJIUoqtl3ikA9D0RDY6JPtUTNbRMtqIPvmp 3IhBunZH0X3IBsfD1Z65u/tGS4brOzzbfr2GZjCknOkHNyboZZW+Srfzroo7RAEoO/pI q2byz+1NUiJlAlx/7mHL2gOiRiN/JEO0Z30KHP2b/L6Jk8N5/83UyRUxRxgpigpqWloc xHsw== 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=MnQI8/HCLz0q0movPmtrdGseM2RTyfTA0eXNijbkDbM=; fh=A3NghPjUcaYWJrBEcBDmjinT5n8U7kPeBkd9SVrhfnk=; b=WbLhfXdsdsTWkWCg4MSMuti0pVq342mo1KH3VWb60qpy9qWM7leR0l0q4k3c3PZPsT +1YIQ/1zlTDWYxxc2D+XlT9/J3UD9DqM8980beiPWCNVWjJTpI9af6XSrrsoYhHsbG/z S+Czbxo9TgJE0fQt/Ug/Rr85fKxzb88y+cwTR2Jnl70v3mxTP12SBaIhm0+D3On9IiLq Wfspg0QfCuEWw6x8XMgFH/7g2EwSXM+q4+mgNscnCYVpSGmRsOHZ+RPDRTt6I/Rgj2Co FGWaFX9eEVEOYyJHgFGaSS834LkmU5KHnZyzw/DuHfNpNkQGEQYXVhwjz520PdG9W/go NbCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@subdimension.ro header.s=skycaves header.b=AADHLrC3; spf=pass (google.com: domain of linux-kernel+bounces-10725-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10725-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 v12-20020a63480c000000b005c6faf0a66asi6381791pga.236.2023.12.24.06.37.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Dec 2023 06:37:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-10725-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=AADHLrC3; spf=pass (google.com: domain of linux-kernel+bounces-10725-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10725-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 4AACCB21710 for ; Sun, 24 Dec 2023 14:37:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8736311723; Sun, 24 Dec 2023 14:35:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=subdimension.ro header.i=@subdimension.ro header.b="AADHLrC3" 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 7D63C568C; Sun, 24 Dec 2023 14:35:19 +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 B437E28B53A; Sun, 24 Dec 2023 14:35:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=subdimension.ro; s=skycaves; t=1703428511; bh=FYSVyc6a7gii4XVzcpbGbqQQ/0VcN0hGzmBnFOnWCwg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=AADHLrC3QN1GkN+tXoceO2jYNkiS/M17KCoF4UyPfPmanJkoyLdPrYmVX/951q+Ob z7b7T4Ujxa1UglFABi+t4y0Ht4SRzyFrIBTPzoBiyDZ4TpAZQPLpTKzr+GL+HQoSSK Rf0y94yYuKLMKlSnKiQT8v1uGsFCy6YwNAwrwxQk= From: Petre Rodan To: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Petre Rodan , Andreas Klinger , Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley Subject: [PATCH v2 03/10] dt-bindings: iio: pressure: honeywell,mprls0025pa.yaml add spi bus Date: Sun, 24 Dec 2023 16:34:48 +0200 Message-ID: <20231224143500.10940-4-petre.rodan@subdimension.ro> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231224143500.10940-1-petre.rodan@subdimension.ro> References: <20231224143500.10940-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: 1786174406562377485 X-GMAIL-MSGID: 1786174406562377485 Add spi based example. Add spi-max-frequency property required by chip specifications. Add additional maintainer. Signed-off-by: Petre Rodan Signed-off-by: Andreas Klinger --- .../iio/pressure/honeywell,mprls0025pa.yaml | 26 +++++++++++++++++-- 1 file changed, 24 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 e4021306d187..430496b047c7 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. Both are supported. There are many models with different pressure ranges available. The vendor calls them "mpr series". All of them have the identical programming model and @@ -88,6 +88,9 @@ properties: Maximum pressure value the sensor can measure in pascal. To be specified only if honeywell,pressure-triplet is not set. + spi-max-frequency: + maximum: 800000 + vdd-supply: description: provide VDD power to the sensor. @@ -135,3 +138,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 Sun Dec 24 14:34:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petre Rodan X-Patchwork-Id: 183060 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp2161180dyi; Sun, 24 Dec 2023 06:36:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IGS6fUWK5dHCBgiyGkaX8KU0Jmv+XonaN6/v4MJ1FUHU5Op24PDXVSJIFsfebumQ8uNfRiA X-Received: by 2002:a17:90a:5148:b0:28c:120:2dfd with SMTP id k8-20020a17090a514800b0028c01202dfdmr2553159pjm.69.1703428604324; Sun, 24 Dec 2023 06:36:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703428604; cv=none; d=google.com; s=arc-20160816; b=o4/AIxzSRAygcOIKq1INDQD27gDIbDsACb8jl8l0DmVtj3rtkeZUS4jrGdFu5cBMQi PMo3t+UlAg8RXR+nPrqocrLDtVhZOzMizKvUbexN9+2DjF+DkpYENoSDI7J9ycUoSN5U tFIi0vVtAtpzq6+6+pFnPFvdAwXK8peqS35WqTujomihSA18tP+PLjguGVIgceYvZSiS WwUR+YTCTUyifpV1LEfjy92IeTSUfuBlkwn5qduLxOhi5kmDjRqBXMQ7UEmLUb6HAogF YcLdI5DUu6wwmypclmZycSEW2fMmsNvJckcNCuoeUGQz+0VI3qYuiWaHQF3mk6jKkX3G 5K/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=aGd8OCxVSGDYHMl4aMCuED8TchwzIDqQ0WsMBC/SPLY=; fh=cuSrpdmFbNnIGKLvcD6905UtzyKVEbJe+tTFY3eiseU=; b=Xr4ekg3cGui6txmQ2Mxhg7vh3LUlD1hkTp2yi3JkIDCwYHx4t9I7y7sBy45cv2TTK3 oEqBkBRmHeaRKeR4kyp3tW0AG4CIa2cRZ5YHfv+e+7pnokDNfFXCWSj2eU2nZzJNnFYO qAgVfHySNMOBULsT+eq5wDVX833kmflOJDhZTEMTx4lvL7ORxhny9BlcgpFQk722D8+r x63mFKAFbl4SA1BVZE0zWin85b49Gfo2eDQKsqNfV+Tn7v7EQfKFqIuXJtNWIpEN3Br2 73AapdR/6K0PaN228AUNDoqAhipzi1iwbUQkfkegiRXzYOAGYTOhRlb0R5keUrN93+k1 oAUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@subdimension.ro header.s=skycaves header.b=S7n3rG5V; spf=pass (google.com: domain of linux-kernel+bounces-10724-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10724-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 n10-20020a17090a9f0a00b0028beed57779si6221221pjp.123.2023.12.24.06.36.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Dec 2023 06:36:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-10724-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=S7n3rG5V; spf=pass (google.com: domain of linux-kernel+bounces-10724-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10724-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 1BAFA282063 for ; Sun, 24 Dec 2023 14:36:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 749CE101C4; Sun, 24 Dec 2023 14:35:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=subdimension.ro header.i=@subdimension.ro header.b="S7n3rG5V" 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 7D6125677; Sun, 24 Dec 2023 14:35:19 +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 2833528B586; Sun, 24 Dec 2023 14:35:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=subdimension.ro; s=skycaves; t=1703428511; bh=VhoWuBoCBEakCVIBAnazDcOgZVIKUnaIyUzxFGulZjQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=S7n3rG5V2AITRn+noHfqNeZVANnQwFLsqD/jCmUXTK/8sPdKhbHtLcH/L3swrGRMp 9L+XiVcqEqQHU7mfGwxjYHRarYX4wldGFPv5q2lHHJFPjC8kmpVM7r+eMwaervbmue ltlzz1lfDYnBQsvpobI/+z/JZuB/Y173k3nZSJGE= 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 v2 04/10] iio: pressure: mprls0025pa.c fix off-by-one enum Date: Sun, 24 Dec 2023 16:34:49 +0200 Message-ID: <20231224143500.10940-5-petre.rodan@subdimension.ro> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231224143500.10940-1-petre.rodan@subdimension.ro> References: <20231224143500.10940-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: 1786174352288857499 X-GMAIL-MSGID: 1786174352288857499 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. Signed-off-by: Petre Rodan Signed-off-by: Andreas Klinger --- 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 Sun Dec 24 14:34:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petre Rodan X-Patchwork-Id: 183066 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp2161710dyi; Sun, 24 Dec 2023 06:38:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IEDBAVkaylUB6AsRWVxhCPV9wMI7Pzilk+YZx/E2iEHfyosOEGxS8DUf2wQ/lwnPKBGAfSj X-Received: by 2002:a05:6e02:20ec:b0:35f:f59f:96c5 with SMTP id q12-20020a056e0220ec00b0035ff59f96c5mr3260096ilv.36.1703428685099; Sun, 24 Dec 2023 06:38:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703428685; cv=none; d=google.com; s=arc-20160816; b=bZSu117ZXI/sbQQYUM8DdlLxJkexfxVn7W3K37r3qYhob4sZ+Pa2U2Zj9S3PjYDTLg yWTvvEv0RTrrhg5VzvIQasrAxiEbs4CQO+nPMNhjMXuB+o5GcIN5gnMgO1AV8GP+64+C g3ddoQ+Qahy7sTYTjdnwOFyJ2aq8QqoGiuW9L+tZFMZDV11My+qdEU+yQnfWmAhPjslf qQeqxdI9Xl6powcytZ3Fpu6XckkBL9tNmcpOpLmhUVUrDpbTUBXAsqXvWO4Sc3R4SORS lEYQNP/yrdnq7tTG7dOnorAb1fJK/m8g4ZEKipF6skKFLBmWBblxDCHj+9FOHGalXLbb 6tGQ== 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=l+WbjiSPttgkzMPObEerdUnw+7bIGedu47TBP2OO5E8=; fh=cuSrpdmFbNnIGKLvcD6905UtzyKVEbJe+tTFY3eiseU=; b=rolGIFLzSeICTkd+maJ5PeVX7WjyIYWWtYvQi3MvshU7Vtc0CwQluml7zAILtesRJx ML2PvFQ8Jbh9DiL3yFTnLSg6W6pRdTXlFkoyIOjmz+OmueEOt1nRW2heFzuNBEZXHJXn v2uaEPmflj1SSZ9M5ar4JCPOZIpuRmp7KTWcRObeeXzSAm2oNrBQrmVEA3+nM60TPuRr PfG5VmAM8BDTl8r4zhI7Xz4//pxqYPZzo0R41LHeFV+ZgYoTewsp+q4M8jE0qyBy1SQL HCqtUIDv3nRDIfMWpt2nb0Tio3z5hTp7NPwX0B0QZhmVzawDi2jJO7JpxtbmjApW8Hba 73Sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@subdimension.ro header.s=skycaves header.b=DFtXG4Gv; spf=pass (google.com: domain of linux-kernel+bounces-10731-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10731-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 m9-20020a17090ab78900b0028c01403f68si5009684pjr.47.2023.12.24.06.38.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Dec 2023 06:38:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-10731-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=DFtXG4Gv; spf=pass (google.com: domain of linux-kernel+bounces-10731-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10731-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 D4D6D28207E for ; Sun, 24 Dec 2023 14:38:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0BD1916419; Sun, 24 Dec 2023 14:35:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=subdimension.ro header.i=@subdimension.ro header.b="DFtXG4Gv" 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 CE769C8FF; Sun, 24 Dec 2023 14:35:20 +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 908FE28B587; Sun, 24 Dec 2023 14:35:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=subdimension.ro; s=skycaves; t=1703428511; bh=TorcAZcZKDG1z0F/unbmrv9wp4dcwJcvTKt25PvrhyE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=DFtXG4GvUwQ2ns94vrVKLH0jDz6XEmK/tdCJCMoG/Nmm2tHtMZDwKFP3O9vfgLJ4K plV4eWge9vXJxKGFZcI2xrM9AjVBtPQW2V7gHSg0WOCCmnZAbPFj33cjs4cQ0zr7Uu 8qgbNpyfkPHqEqs6QZQp4o7KVkg9D4KVpK3djA+8= 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 v2 05/10] iio: pressure: mprls0025pa.c fix error flag check Date: Sun, 24 Dec 2023 16:34:50 +0200 Message-ID: <20231224143500.10940-6-petre.rodan@subdimension.ro> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231224143500.10940-1-petre.rodan@subdimension.ro> References: <20231224143500.10940-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: 1786174436835335600 X-GMAIL-MSGID: 1786174436835335600 Take into account all 3 error flags 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 Signed-off-by: Petre Rodan Signed-off-by: Andreas Klinger --- 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 Sun Dec 24 14:34:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petre Rodan X-Patchwork-Id: 183067 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp2161720dyi; Sun, 24 Dec 2023 06:38:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IEp7MZouna1q1a/rJ/ozk9nbkajUvQSKXjV0iRjPx5jhQswlkKP+N8IYK6PiUMArSeyKwka X-Received: by 2002:a05:6358:9141:b0:174:b2f7:52e6 with SMTP id r1-20020a056358914100b00174b2f752e6mr4475928rwr.43.1703428684747; Sun, 24 Dec 2023 06:38:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703428684; cv=none; d=google.com; s=arc-20160816; b=UBTZ9UnKjPCyJMjJhZpqo1bTJ7UX8yM1YKEvgwTDkdet60XXR7NaeGWFtyTRozgyzT ahCPS2J6FLua0OLibMaCno7hCobkqFAEwmcTKUMe6qgoS6stQWqonScyakVt7TIX45zB Ynj6qjN4fUybHcKOdQtrxFnNvQL3yh6DieuEKk4ah1q9PBhdcEanLX/MjDXXstW5t3uj Xrl2c5NmsvcHcMK7Nlgct2YWfzTIp9S8D5y8bcQgMaiygAdMyyTA1WhdPLJpOcGbTZir FgtpPNw04sQR2T6obYl3hNLUdVILaZW/33I8drnZFtTRvstjOpC/hHzt32ELlKmzREx8 OSUg== 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=6TZQ4Ug7lcqqlOma6w90uAoBMvFhOU+W38A+OCSroUk=; fh=cuSrpdmFbNnIGKLvcD6905UtzyKVEbJe+tTFY3eiseU=; b=O/VjL6lA2E/yP+gigr7AcTn7spIHMB+mX6wlQ83kfmWp2l1EaMWVJZQhMkU0bGrFc2 MeKD/e+G2ttbHcCvbh24Vht85W6wf7NSCM1kt/32YrPiSwBZ7STUqg6xRJg8X4W96zfU VdtJdV9BucNmPpurMrx2aQeJb+Lfy3w7/DltL6ZUhITbd/Pp/NQ+t3erypNgs5BR7Kcj 6n4cgPD6VUV5INorG+oboqL/F5ix0fVd0KKxTiSNGeRY695sylhh62Pu7itKsaC74qsP 86xm0bKYNpqNzpkQXmw++aySb3WCK7OlwzLAUg979FBjR59qwMiJ83jlrqwbgBNfb1Tp 9ycQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@subdimension.ro header.s=skycaves header.b=UexyF4zT; spf=pass (google.com: domain of linux-kernel+bounces-10726-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10726-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 o8-20020a17090ac08800b0028bc7cefee2si6586697pjs.34.2023.12.24.06.38.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Dec 2023 06:38:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-10726-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=UexyF4zT; spf=pass (google.com: domain of linux-kernel+bounces-10726-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10726-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 B1BA4B216B5 for ; Sun, 24 Dec 2023 14:37:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 396A2134D1; Sun, 24 Dec 2023 14:35:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=subdimension.ro header.i=@subdimension.ro header.b="UexyF4zT" 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 CE793CA62; Sun, 24 Dec 2023 14:35:20 +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 F276B28B589; Sun, 24 Dec 2023 14:35:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=subdimension.ro; s=skycaves; t=1703428512; bh=HLqQLEVNtiMPyM7hryG6OMvLH1BriN5OL0vabmTcwRE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=UexyF4zTPQ68Hmc6DOF9oHqK9Bws8Gl1X+lGqKuwYsVkDhIeyNI3yR+CKNEkGtH5i Lk7nkHiZmXeM9Xzu/CYRuYmcZJ7AD5IsJjW09cUhKWMvxWDQrMhR/nDnayXaBm92xh FxRVbWXoglGfuclOf2n6CjiG0hKbeYH/x6rkUeAI= 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 v2 06/10] iio: pressure: mprls0025pa.c remove dangerous defaults Date: Sun, 24 Dec 2023 16:34:51 +0200 Message-ID: <20231224143500.10940-7-petre.rodan@subdimension.ro> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231224143500.10940-1-petre.rodan@subdimension.ro> References: <20231224143500.10940-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: 1786174436509164522 X-GMAIL-MSGID: 1786174436509164522 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 dt has been initialized. Signed-off-by: Petre Rodan Signed-off-by: Andreas Klinger --- drivers/iio/pressure/mprls0025pa.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) -- 2.41.0 diff --git a/drivers/iio/pressure/mprls0025pa.c b/drivers/iio/pressure/mprls0025pa.c index 233cc1dc38ad..63c46592956f 100644 --- a/drivers/iio/pressure/mprls0025pa.c +++ b/drivers/iio/pressure/mprls0025pa.c @@ -375,11 +375,8 @@ static int mpr_probe(struct i2c_client *client) "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; + return dev_err_probe(dev, -EINVAL, + "driver needs to be initialized in the dt\n"); } data->outmin = mpr_func_spec[data->function].output_min; From patchwork Sun Dec 24 14:34:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petre Rodan X-Patchwork-Id: 183062 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp2161590dyi; Sun, 24 Dec 2023 06:37:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IEGw1q+PhGebV9tz6IrgmEomy+BaBhCKClwXb/w+5jxu4Jy63Co2Oqaq1wR/zUhxJh/1aTQ X-Received: by 2002:a05:6602:19c1:b0:7ba:b267:db56 with SMTP id ba1-20020a05660219c100b007bab267db56mr1788335iob.21.1703428663804; Sun, 24 Dec 2023 06:37:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703428663; cv=none; d=google.com; s=arc-20160816; b=WHYiBUoCwdWI7ic2v1zHVqnJg6lrC2IlIutMti3ZwqDqrjzEK7xFeZEnj3/BnEJjGJ A1IxdZ1rAqcPaRshJgflBUzLRZ8x0voNyT/9HKNSG3W9YkxUYJO5Z3xa1kOlCa+YlcC4 Py4x5LtIJNE/5T6uPKBF5z1gWBftK2EPr64pS53hP8goZrXO/DQmLWWSfmVcyf4aib+o Qh6cIIVmusnWSpu6BP3rTfFHjGBXytmpwk3+TReVBU/WbB2IM5GaNTg0bsfST3btU/Wd fgItQhKho96DEeGscIQ1zoJYVUBID513mHu7H01pFNMGwVVKAsa8BIjHYr7muAqMFDox +MiA== 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=QTkb6RhOTGSTo16LRST8PM0qdumhrLkQ7/Lpe0bJbx0=; fh=cuSrpdmFbNnIGKLvcD6905UtzyKVEbJe+tTFY3eiseU=; b=vYTO3d/gHpYoLOzneT0bjq1xrd9Ok8qq2BQI1+XQoHP+2wgaZjyY6TsdJZML9XOK/s UO6Bu/5vJgKnVSxmjSdaRHJiQ4CXJak9CsV9VXWas/gH3zdhs1psAmIpa/qudWvGnLu6 biMIXAWKJLxmJ31H3bGIDjgL/zB3k5EuVsKLtro65eSBee/lctuaVRX5+2tefprTXe6Y ugKbQ4YqZbIJ12sXDAmKZsLzc2t7RNpXOm4TBQRyEnk6UOPm3Wof9aODyYWxk4vUfz8D +/NbIAAVxwi0178n12Y4mL+TjHyE3+sfD5PcBfWnw2uRe8nOUPrLezj6sck8Pi3Nv2j3 xcQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@subdimension.ro header.s=skycaves header.b=T8f1YLlR; spf=pass (google.com: domain of linux-kernel+bounces-10727-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10727-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 r2-20020aa78b82000000b006d9ae44772esi1588248pfd.7.2023.12.24.06.37.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Dec 2023 06:37:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-10727-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=T8f1YLlR; spf=pass (google.com: domain of linux-kernel+bounces-10727-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10727-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 90130282029 for ; Sun, 24 Dec 2023 14:37:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 396F613AC6; Sun, 24 Dec 2023 14:35:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=subdimension.ro header.i=@subdimension.ro header.b="T8f1YLlR" 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 CE732C8FD; Sun, 24 Dec 2023 14:35:20 +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 4B76E28B594; Sun, 24 Dec 2023 14:35:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=subdimension.ro; s=skycaves; t=1703428512; bh=u4MBcXGQ5BHNLiXLVpwRBu5az/Wm1HwVbxxZebHWSRs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=T8f1YLlRqHBCeeEuUgxiKMENmQ1qjKyp03rZ9a9ItAp4OC1IeRB+1hWM2f64AhMWx jMO2YM0PCEhzMcnU63iOAhl20roIr1NtXD/Z+gtkjUv+71k3eiQQ6ciXD4JuUSr72U oEjQmxFMUSaaJLi95ecCxHwDBve/RQrUbhlzpiEI= 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 v2 07/10] iio: pressure: mprls0025pa.c whitespace cleanup Date: Sun, 24 Dec 2023 16:34:52 +0200 Message-ID: <20231224143500.10940-8-petre.rodan@subdimension.ro> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231224143500.10940-1-petre.rodan@subdimension.ro> References: <20231224143500.10940-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: 1786174414152575746 X-GMAIL-MSGID: 1786174414152575746 Fix indentation and whitespace in code that will not get refactored. Make URL inside comment copy-paste friendly. Signed-off-by: Petre Rodan Signed-off-by: Andreas Klinger --- drivers/iio/pressure/mprls0025pa.c | 38 ++++++++++++++---------------- 1 file changed, 18 insertions(+), 20 deletions(-) -- 2.41.0 diff --git a/drivers/iio/pressure/mprls0025pa.c b/drivers/iio/pressure/mprls0025pa.c index 63c46592956f..e14cdee7989f 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); @@ -355,15 +352,16 @@ static int mpr_probe(struct i2c_client *client) if (dev_fwnode(dev)) { ret = device_property_read_u32(dev, "honeywell,pmin-pascal", - &data->pmin); + &data->pmin); if (ret) return dev_err_probe(dev, ret, - "honeywell,pmin-pascal could not be read\n"); + "honeywell,pmin-pascal could not be read\n"); + ret = device_property_read_u32(dev, "honeywell,pmax-pascal", - &data->pmax); + &data->pmax); if (ret) return dev_err_probe(dev, ret, - "honeywell,pmax-pascal could not be read\n"); + "honeywell,pmax-pascal could not be read\n"); ret = device_property_read_u32(dev, "honeywell,transfer-function", &func); if (ret) @@ -384,14 +382,14 @@ 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) { @@ -399,27 +397,27 @@ static int mpr_probe(struct i2c_client *client) 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 Sun Dec 24 14:34:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petre Rodan X-Patchwork-Id: 183063 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp2161656dyi; Sun, 24 Dec 2023 06:37:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IE5dNymCpwKXrK5xdkJ9D/v8WbpllZOCjHlUZPxMyhMJ+fTHO8aFENMXYRBMPmTvUfBVz6e X-Received: by 2002:a50:cd97:0:b0:554:5192:5bdf with SMTP id p23-20020a50cd97000000b0055451925bdfmr2789283edi.43.1703428676625; Sun, 24 Dec 2023 06:37:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703428676; cv=none; d=google.com; s=arc-20160816; b=GxwHcK7Eew/Onr8nYAyl/eXwbggRFhmCUT8xHkugfPIY7KyCHj6N4HM8/5n+lWNbiA 8nkZO5qCej8j8tY/fv34papleQkRlOLqYqrXQCzLQazMyMffKiG0PgxtS+4ibQQSurC6 vI4fg6EwpDtchASLLkGAmpbtE8frBaxPsRuR+d8zx8lVfpcI1KWgIjyzqqhMhjYvTmci /j4CIIjVVemXSgtaoMapssQQv6yCNGgxFJSB3c3fMSO3+WXUgh7N36maAMNEqH74wBYO O/t7G0mff04HYqJpKgG+9k2rNtMc6QCK4XD3HqyN+0V8fM6umVhECc0q2g/zD+g64amQ ulNw== 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=5bsFGFiM/nxCLz+K6JRx9iF5m/sLvC7IqIf5obwgMFk=; fh=cuSrpdmFbNnIGKLvcD6905UtzyKVEbJe+tTFY3eiseU=; b=OojmuBwoW4pnSHqM5LJgk9uO4NZNP27yEW53qVciPp4O7q4vpUqj3G00+MweeOGRVJ YAp67cxiDi/b8I3mJdJqNZts1E/HSkLKvVh+PcfbQJLsH8tk6/z17yPmCCp65LLd5EoF ZCh7k1//VDTQvXRbU6puyQYPgLIfk07dBFoATHazD/QwXqN4q7KyJ/wFfTmQek9trQDO lcnHG+Mq42QqWU5sieUZYMJ10Rn9eSiW68dLXRpOhfh3hNJGoUua+zDMXbKf3qVy6qc/ T5zIVt38sSuWx0iFar1KE9OM0AZRuf8l4XiFEQbEgWjxo5WLiI+X4cZhi2KJfRIp44hj uj9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@subdimension.ro header.s=skycaves header.b=ok3lCv1n; spf=pass (google.com: domain of linux-kernel+bounces-10728-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10728-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. [147.75.80.249]) by mx.google.com with ESMTPS id b16-20020a056402279000b0055389f873f3si3806489ede.280.2023.12.24.06.37.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Dec 2023 06:37:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-10728-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@subdimension.ro header.s=skycaves header.b=ok3lCv1n; spf=pass (google.com: domain of linux-kernel+bounces-10728-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10728-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 1E77E1F218B9 for ; Sun, 24 Dec 2023 14:37:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 94A0615488; Sun, 24 Dec 2023 14:35:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=subdimension.ro header.i=@subdimension.ro header.b="ok3lCv1n" 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 E9692CA6F; Sun, 24 Dec 2023 14:35:20 +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 C0B6D28B595; Sun, 24 Dec 2023 14:35:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=subdimension.ro; s=skycaves; t=1703428513; bh=cqOZFfGH+zbpKFTmFEpDpsmCmNKgk5D3iCAR6d0d/ZY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ok3lCv1nGTo9OpjeLOxUbVpjAqwoUhUdt/s6WF0FGrwa7HhFtzodH4ZBxcGG7zLPD 7BhRjR8o78+V8sn+Ab0Eb2C7IfmCZEu8bgTHlogPODMkIIk0btO3CzsOjELSs4NTLr XvHGbHGdIe6jbFXRnmoHh/69AwQfCDb8HDwMWGQ8= 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 v2 08/10] iio: pressure: mprls0025pa.c refactor Date: Sun, 24 Dec 2023 16:34:53 +0200 Message-ID: <20231224143500.10940-9-petre.rodan@subdimension.ro> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231224143500.10940-1-petre.rodan@subdimension.ro> References: <20231224143500.10940-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: 1786174428290260372 X-GMAIL-MSGID: 1786174428290260372 Refactor driver by splitting the code into core and i2c. Seemingly redundant read/write function parameters are required for compatibility with the SPI driver. Signed-off-by: Petre Rodan Signed-off-by: Andreas Klinger --- MAINTAINERS | 3 +- drivers/iio/pressure/Kconfig | 6 + drivers/iio/pressure/Makefile | 1 + drivers/iio/pressure/mprls0025pa.c | 203 ++++++++----------------- drivers/iio/pressure/mprls0025pa.h | 100 ++++++++++++ drivers/iio/pressure/mprls0025pa_i2c.c | 98 ++++++++++++ 6 files changed, 267 insertions(+), 144 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 3029841e92a8..cbb163e1b311 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -9725,10 +9725,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 e14cdee7989f..cb5d6c0cca7e 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 @@ -30,13 +29,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 +70,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 +81,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 +108,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 +125,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 +153,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 +169,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 +253,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,32 +284,36 @@ 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", + ret = data->ops->init(data->dev); + if (ret) + return ret; + + 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); + + ret = device_property_read_u32(dev, "honeywell,pmin-pascal", &data->pmin); - if (ret) - return dev_err_probe(dev, ret, + 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"); - 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 { + + if (data->pmin >= data->pmax) return dev_err_probe(dev, -EINVAL, - "driver needs to be initialized in the dt\n"); - } + "pressure limits are invalid\n"); data->outmin = mpr_func_spec[data->function].output_min; data->outmax = mpr_func_spec[data->function].output_max; @@ -394,7 +332,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, data); + IRQF_TRIGGER_RISING, dev_name(dev), data); if (ret) return dev_err_probe(dev, ret, "request irq %d failed\n", data->irq); @@ -421,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..7d7bd21bda95 --- /dev/null +++ b/drivers/iio/pressure/mprls0025pa.h @@ -0,0 +1,100 @@ +// 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 + */ + +#ifndef _MPRLS0025PA_H +#define _MPRLS0025PA_H + +#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 *); + int (*read)(struct mpr_data *, const u8, const u8); + int (*write)(struct mpr_data *, const u8, const u8); +}; + +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..89d6a206192b --- /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 + +#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 != 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 != 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 Sun Dec 24 14:34:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petre Rodan X-Patchwork-Id: 183065 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp2161704dyi; Sun, 24 Dec 2023 06:38:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IHnyNXFizvJBs6Vyu4qPSNhJU9CK4hJQjzwJoT9yhCu2QYMeXm6LhPR3iY9DYpWeCpMIpvJ X-Received: by 2002:a17:903:1d1:b0:1d4:5276:7667 with SMTP id e17-20020a17090301d100b001d452767667mr175283plh.18.1703428684073; Sun, 24 Dec 2023 06:38:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703428684; cv=none; d=google.com; s=arc-20160816; b=nGwvYNXLPyPAQlxMumte0dMaSVLaYMlJIdUBcKLiQwe2N5TUy1tB1iQRAgjLLQZ5xO caVqQLG9vbr+ZVhCZAwP2s56FMOs1JKMYiBO0hanbDnv6viCQhgxmWUHjV76Fcn138za tu79xmMcrGW3+fVP1eDUINQfz3QbOeiOHOYv+LdqtK6e3/GHq9dx+q4TZfOuZSlOM3ec ZhsF5UEjD2xPaRqK3uUQES+BFC69jrVQ635tA5qWyZfn/qYaID7rQiU5trDp91A/XIby VjP9yOXxNxRWFZKvhwXiockYaJO2DSMOwF+Z2TcNi80QtfXraEJiXe9np//m1DU7AN/p iU8Q== 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=4IEjATarPqwZH4t7oKN9h+rpoo+02nnZFDi4quCH38s=; fh=cuSrpdmFbNnIGKLvcD6905UtzyKVEbJe+tTFY3eiseU=; b=KsSU4BpzlH+IMUeIG77PA5ZvIv4vRYE2tygCUD5i3/+1VHa/BoQJj+2yf7StKQL44P PErRP1pe7jlJJPck96wPv+BmhpyBnLosy/zW9b6VsEuRYo+GZ0kfHMQgIbEouyUPat/O sUSK8n+XOptMLHJ+yZqQffqVe4j1zVRtMreJlmx9YZ832Wr3MkqNzd6PaPuvsBl5INUJ 8q6lz80mdqcp6noLa/3P8GJyn/WeupX9NcLgL2mXBLoNIvB6cX3R58Sjwx2Oxqfxjztq tZTNwLNc7ubPZtJXKojBkH8WAq3zBBVK/dVfUM2mIb4aUCX4Uhu8Ewe3EJfKls4OGVvC OQDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@subdimension.ro header.s=skycaves header.b=IJtgSSkj; spf=pass (google.com: domain of linux-kernel+bounces-10730-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10730-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 y8-20020a17090322c800b001d439a425bcsi2488112plg.514.2023.12.24.06.38.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Dec 2023 06:38:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-10730-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=IJtgSSkj; spf=pass (google.com: domain of linux-kernel+bounces-10730-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10730-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 CCEF42820CC for ; Sun, 24 Dec 2023 14:38:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 06D2816404; Sun, 24 Dec 2023 14:35:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=subdimension.ro header.i=@subdimension.ro header.b="IJtgSSkj" 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 AB8C0D2E4; Sun, 24 Dec 2023 14:35:21 +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 258D328B596; Sun, 24 Dec 2023 14:35:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=subdimension.ro; s=skycaves; t=1703428513; bh=igQQMcRnZ9Jt9l924W/q+qEMsBoB7ucqMQshinmhQGc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=IJtgSSkjcotM5kNdFcwapPQ28SbdijSLLU27krN5hA+4vTlImmr2zplxD6jOMfvEv ZNHph03LHU7rOSUhFq/vGERt1Q9afEfa5Ay0KKMBVGaX8SsiIRG09ff+CdRYSq9E6c FNxC+LSEcB/kmVB076XqBU46Vvmfh1colzFm0cVA= 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 v2 09/10] iio: pressure: mprls0025pa.c add triplet property Date: Sun, 24 Dec 2023 16:34:54 +0200 Message-ID: <20231224143500.10940-10-petre.rodan@subdimension.ro> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231224143500.10940-1-petre.rodan@subdimension.ro> References: <20231224143500.10940-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: 1786174435691101892 X-GMAIL-MSGID: 1786174435691101892 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. Signed-off-by: Petre Rodan Signed-off-by: Andreas Klinger --- drivers/iio/pressure/mprls0025pa.c | 102 +++++++++++++++++++++++++++-- 1 file changed, 95 insertions(+), 7 deletions(-) -- 2.41.0 diff --git a/drivers/iio/pressure/mprls0025pa.c b/drivers/iio/pressure/mprls0025pa.c index cb5d6c0cca7e..90aed290b6c2 100644 --- a/drivers/iio/pressure/mprls0025pa.c +++ b/drivers/iio/pressure/mprls0025pa.c @@ -81,6 +81,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, @@ -258,6 +330,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; @@ -299,17 +372,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", + 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, + 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 Sun Dec 24 14:34:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petre Rodan X-Patchwork-Id: 183064 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp2161683dyi; Sun, 24 Dec 2023 06:38:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IE+x3NVj/PZOuXurL5TQAAFY91JOKdGEMh4aqoEFEDdWU/pDhLN1rPLBsUnKJ5a32MsdKZA X-Received: by 2002:a05:600c:524b:b0:40d:566f:cb41 with SMTP id fc11-20020a05600c524b00b0040d566fcb41mr17379wmb.93.1703428681509; Sun, 24 Dec 2023 06:38:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703428681; cv=none; d=google.com; s=arc-20160816; b=IH5n3vjqyOrE/8eTK7XqykF7SewYo7rUJXXUVdRKCiPGmwG3/KqUzW7D47i3hEtXLf zr3uHkayxnek3rWBTr1PtQz9Pa2EQicqht7T7ihZNmTUqV9dv8/69fWuP7LSXZNssqTG EoQHFuwVSzybWXfoNN22GmP1SeFNszqPzUXjqrbUH2C9sR6Cih+tenr3ZZsF+sa0Ajzx H+ARqqmQgwG4mEWP+9oGq6GY8YY8flu6uOV4MM5F4TZnleayfA+RLSEgXsjk8MVpiBxZ BkNZIyYWLgHhTZlNb+vIwq9RoIqf/tY11aEj+F5dr6JuIJvNBg9pEQqcnB/a0QgYQRwh x3Ug== 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=8w4/VJ/ygPCBAB67H54TxgV1QezOZ9xo+IEAmceO3Co=; fh=cuSrpdmFbNnIGKLvcD6905UtzyKVEbJe+tTFY3eiseU=; b=mSQJnPbXT0FLz/OHOqN4haOzQprO0Vfh8uONF9qt7FAIRQ+pXcCCL9/eV0obNZTVlM NvQCR00RawBC5FvDm6CSgZcnXBgKF9xwFqOOHNHUDqOyyCWGEpWvnsdB7jc1qfNm5/HQ l/N+TyFYRSKEZoqdFaEeWlbd0Iu9z+v3y6y+msszgBqJf1fmZSHBPCPcoJcEw0ap1e2o gWmFr4r95O8I5U2AdN97pbq/nO2GHJWqY5NCvnWRoNyLeV8fNGj3SMKMVO2+eHc5eMhT 5IZT362ZroSVYf6FXX4YIJJAY0ehJHVEHbF5jTKusx/6nVP/2FuOa5f4YA68v8KgSCrN zQDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@subdimension.ro header.s=skycaves header.b="MDn/w3Yu"; spf=pass (google.com: domain of linux-kernel+bounces-10729-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10729-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. [147.75.80.249]) by mx.google.com with ESMTPS id ca7-20020a170906a3c700b00a2695e0a390si3752622ejb.829.2023.12.24.06.38.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Dec 2023 06:38:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-10729-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@subdimension.ro header.s=skycaves header.b="MDn/w3Yu"; spf=pass (google.com: domain of linux-kernel+bounces-10729-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10729-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 253ED1F2177B for ; Sun, 24 Dec 2023 14:38:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C8CDF15E93; Sun, 24 Dec 2023 14:35:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=subdimension.ro header.i=@subdimension.ro header.b="MDn/w3Yu" 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 AB8F0D2E5; Sun, 24 Dec 2023 14:35:21 +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 761CE28B597; Sun, 24 Dec 2023 14:35:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=subdimension.ro; s=skycaves; t=1703428513; bh=KDRAxKlPjg5H/Rw/NBwFCVs5lMGFbcXAUuvCmLYArFk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=MDn/w3Yue04BzNM1VWayAQyGNCcFVz3ouPJXBLd77fiyiOtQ7Ykhy2+r2W56LmBz6 HJmD3+xx+WfxKOGJdbeOu7nN9Lgtm/C2+QXBcQrIy2QJ7WOlhuRBSy7QhhjELetkOk f5qT3YtSGkpO76jhmVbn6WQDhcxWBI/idtqDwHjQ= 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 v2 10/10] iio: pressure: mprls0025pa.c add SPI driver Date: Sun, 24 Dec 2023 16:34:55 +0200 Message-ID: <20231224143500.10940-11-petre.rodan@subdimension.ro> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231224143500.10940-1-petre.rodan@subdimension.ro> References: <20231224143500.10940-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: 1786174433218074076 X-GMAIL-MSGID: 1786174433218074076 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) Signed-off-by: Petre Rodan Tested-by: Andreas Klinger --- drivers/iio/pressure/Kconfig | 8 ++- drivers/iio/pressure/Makefile | 1 + drivers/iio/pressure/mprls0025pa_spi.c | 91 ++++++++++++++++++++++++++ 3 files changed, 99 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..7ef43a7abc83 --- /dev/null +++ b/drivers/iio/pressure/mprls0025pa_spi.c @@ -0,0 +1,91 @@ +// 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 + +#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);