From nobody Mon Dec 1 21:31:54 2025 Received: from mail.subdimension.ro (nalicastle.subdimension.ro [172.105.74.154]) (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 CBEB227E7F0; Fri, 28 Nov 2025 03:13:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=172.105.74.154 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764299640; cv=none; b=Jbo4q8Eo0/s2ln9FV5lEKPn3ETzqEJJZeliahcAmmiXXe2dWVnpv5CHIgE048QHd7xqG/0vIc0N66NkaU2MCfXiTH+PbLl3xhWGg+sa+wKNhJA7Fc6qFmkyfrNnF+qkSvpZHvJSTvgd5wkGOHDjsqBSfDKos0WFSZ3d2duS7zzU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764299640; c=relaxed/simple; bh=8T/9Cs0/ak+fTfxza5H/0jFjKpC7hE17bPkqIsZm+cg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=CJmR7qzh2MUrZWglHsXLfuHzGsGNoOkFBEPTiCejhxffTc53IZAiqekq1MhYuECibA7xiptl5t+LTAyEbQyX5tafrczHkKf7OGDyqUFUR3QCNxA0itKZDO75jAGoJwtN2DvdivP0Hjom3x/vM82fcnGYrRk1RpO9e5MoiN5IK7A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=subdimension.ro; spf=pass smtp.mailfrom=subdimension.ro; dkim=pass (2048-bit key) header.d=subdimension.ro header.i=@subdimension.ro header.b=PoOd7hmO; arc=none smtp.client-ip=172.105.74.154 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=subdimension.ro Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=subdimension.ro Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=subdimension.ro header.i=@subdimension.ro header.b="PoOd7hmO" Received: from sunspire.home.arpa (unknown [IPv6:2a02:2f0e:3402:a400:e2d5:5eff:fed9:f1c4]) (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 27AB416020A; Fri, 28 Nov 2025 05:13:55 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=subdimension.ro; s=mail; t=1764299635; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BUMvhw3Yrl3BOOsNMul6PT9KsxD7XnHx4PeGl4+PTw4=; b=PoOd7hmOhmfrSPw5qx6i7uYidFfSovS6IyXvu69hx7IADbWjpPx4OpVReI+obIX4+OHqQF oCu+TFPRurWsnZoGMU9huDuwwoz4GcvZlf086ZNUuwmG/OjziJRCUaXkocZbGhnZS/TfxK 8VSuUNJWTgbYPwv3fWkiV6rno0/u9qVbya1lUddUgQevuMrvbN3FVwNSO7GS9ahpVMQYNS zfYQ5f7awOSswGqNsuMPUk0wpvznvQd6VJ1OCVSc2UtdEkfzrpCOcr0OwRiDfIO/PTjCkv JGLgf7XYOUoT9amP99LkKOvNYjddZWl200spwOt2lwZfuy7DFx6xiyrWB6W5yA== From: Petre Rodan Date: Fri, 28 Nov 2025 05:13:26 +0200 Subject: [PATCH v2 1/2] dt-bindings: iio: pressure: add honeywell,abp2030pa Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251128-honeywell_abp2_driver-v2-1-7053748aecf7@subdimension.ro> References: <20251128-honeywell_abp2_driver-v2-0-7053748aecf7@subdimension.ro> In-Reply-To: <20251128-honeywell_abp2_driver-v2-0-7053748aecf7@subdimension.ro> To: Jonathan Cameron , David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Krzysztof Kozlowski X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=5901; i=petre.rodan@subdimension.ro; h=from:subject:message-id; bh=8T/9Cs0/ak+fTfxza5H/0jFjKpC7hE17bPkqIsZm+cg=; b=LS0tLS1CRUdJTiBQR1AgTUVTU0FHRS0tLS0tCgpvd0o0bkFGdEFwTDlrQTBEQUFvQmRDc25wM k02U1dNQnl5WmlBR2twRTI1TXh6YlAwTEhMWjBVM0VkNnRPQWdoCloyYjV5eC9iS3ZtM0x1NWdH aUgvQVlrQ013UUFBUW9BSFJZaEJCb2ltQncrRGJ4UXBFNmlkM1FySjZkak9rbGoKQlFKcEtSTnV BQW9KRUhRcko2ZGpPa2xqQjdvUUFLSzVvZU5LMVZlOGtIWU5VV0xLbEFjOFQyK0ZiUzJSdXBpYQ pwL0FnQ3Vsek1MenZDUXJRUytDTDF2S2hDNVdvdjRPYjF5elN0amd1ZW54Mk9uWjdJWlNWSjFQe kxSanJQYTdmCjl0OWtCTk1YWDl0bmsyK3JqcC9lZlNHZXhCN214YVRvUHFGWFVBRlFNMkpKSE5z TGtMZFhaaWw1ZjNmVjVMZloKUVNaRmJydmllSk9tRytaZGFKOXdKeGpEY3hzZjN0Z0dSSzc0NTV zRVB0aFBPMks5amNmK0srM1lGTzJQd0xocAp5T3M3NWwxYjRLSGE1NWRGVHM4OElUWW41NWpUOT Qyak9kSmd1eWE3UlozQ09ucG9STURMYWh6aHdvcElMeXBPCnBkZDlnQUNKRGNLQWNRaVN1VHVEN UtzOTlXQXpNaTgwcHd0Nk10dzZOanpSQVMwZDFtUXZnTXlLTHIrYUlHLzkKM2JGSWFnc1YwcTk2 bUw2RFV0WXgrQStINXFVNjJReU83SGhhVmdVV1FuWXFVWVowZTFmQk1HSm51b2V0Q2lXZwpFbEt tR1IyaUx5Rlp3SExUb1hOdVNHUEdBa2taL0tkMUVibTRVWUxyM1B5dmFzL2JhL1V1QkhCWEU4YU pjTndtClZUc0RvWUpPdjV6aDZVdFVTNGM4M3ovRGYrbjVST1hELytBb1JLSFgxZStiMTVKUGpWV SswZlVHeEkwZlZmcW4KTDhBQkZLcjRDRkNzaWdGbnZqclN3eEg0SksxMmE1d0VMeDFxUmJjeXF4 T3BTdUxUcnNqb0pxTWY2b0phK0NKawp1cDBNQm1YOUJpSkVFNEhwZ0trbVdVaDlqRkhxRmhDb3N RTU9UUE1TM3VCMFdRV3E4TzFhM1F5RjVDOER5NVIvCnNybUxpeEI5ekdJZHdRPT0KPXhTUisKLS 0tLS1FTkQgUEdQIE1FU1NBR0UtLS0tLQo= X-Developer-Key: i=petre.rodan@subdimension.ro; a=openpgp; fpr=D80A7FC176151935EC3E5FA9CF269999844E7F30 Adds binding for digital Honeywell ABP2 series pressure and temperature sensors. The i2c address is hardcoded and depends on the part number. There is an optional interrupt that signals the end of conversion. Reviewed-by: Krzysztof Kozlowski Signed-off-by: Petre Rodan --- .../bindings/iio/pressure/honeywell,abp2030pa.yaml | 133 +++++++++++++++++= ++++ MAINTAINERS | 6 + 2 files changed, 139 insertions(+) diff --git a/Documentation/devicetree/bindings/iio/pressure/honeywell,abp20= 30pa.yaml b/Documentation/devicetree/bindings/iio/pressure/honeywell,abp203= 0pa.yaml new file mode 100644 index 000000000000..8da39ee43dbc --- /dev/null +++ b/Documentation/devicetree/bindings/iio/pressure/honeywell,abp2030pa.ya= ml @@ -0,0 +1,133 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/pressure/honeywell,abp2030pa.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Honeywell abp2030pa pressure sensor + +maintainers: + - Petre Rodan + +description: | + Honeywell pressure sensor of model abp2030pa. + + This sensor has an I2C and SPI interface. + + There are many models with different pressure ranges available. The vend= or + calls them "ABP2 series". All of them have an identical programming mode= l and + differ in the pressure range and measurement unit. + + To support different models one needs to specify its pressure triplet. + + For custom silicon chips not covered by the Honeywell ABP2 series datash= eet, + the pressure values can be specified manually via honeywell,pmin-pascal = and + honeywell,pmax-pascal. + + Specifications about the devices can be found at: + https://prod-edam.honeywell.com/content/dam/honeywell-edam/sps/siot/en-u= s/products/sensors/pressure-sensors/board-mount-pressure-sensors/basic-abp2= -series/documents/sps-siot-abp2-series-datasheet-32350268-en.pdf + +properties: + compatible: + const: honeywell,abp2030pa + + reg: + maxItems: 1 + + interrupts: + description: + Optional interrupt for indicating end of conversion. + SPI variants of ABP2 chips do not provide this feature. + maxItems: 1 + + honeywell,pressure-triplet: + description: | + Case-sensitive five character string that defines pressure range, un= it + 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: [001BA, 1.6BA, 2.5BA, 004BA, 006BA, 008BA, 010BA, 012BA, 001BD, + 1.6BD, 2.5BD, 004BD, 001BG, 1.6BG, 2.5BG, 004BG, 006BG, 008BG, + 010BG, 012BG, 001GG, 1.2GG, 100KA, 160KA, 250KA, 001KD, 1.6KD, + 2.5KD, 004KD, 006KD, 010KD, 016KD, 025KD, 040KD, 060KD, 100KD, + 160KD, 250KD, 400KD, 001KG, 1.6KG, 2.5KG, 004KG, 006KG, 010KG, + 016KG, 025KG, 040KG, 060KG, 100KG, 160KG, 250KG, 400KG, 600KG, + 800KG, 250LD, 600LD, 600LG, 2.5MD, 006MD, 010MD, 016MD, 025MD, + 040MD, 060MD, 100MD, 160MD, 250MD, 400MD, 600MD, 006MG, 010MG, + 016MG, 025MG, 040MG, 060MG, 100MG, 160MG, 250MG, 400MG, 600MG, + 001ND, 002ND, 004ND, 005ND, 010ND, 020ND, 030ND, 002NG, 004NG, + 005NG, 010NG, 020NG, 030NG, 015PA, 030PA, 060PA, 100PA, 150PA, + 175PA, 001PD, 005PD, 015PD, 030PD, 060PD, 001PG, 005PG, 015PG, + 030PG, 060PG, 100PG, 150PG, 175PG] + $ref: /schemas/types.yaml#/definitions/string + + honeywell,pmin-pascal: + description: + Minimum pressure value the sensor can measure in pascal. + + honeywell,pmax-pascal: + description: + Maximum pressure value the sensor can measure in pascal. + + spi-max-frequency: + maximum: 800000 + + vdd-supply: + description: provide VDD power to the sensor. + +required: + - compatible + - reg + - vdd-supply + +oneOf: + - required: + - honeywell,pressure-triplet + - required: + - honeywell,pmin-pascal + - honeywell,pmax-pascal + +allOf: + - $ref: /schemas/spi/spi-peripheral-props.yaml + - if: + required: + - honeywell,pressure-triplet + then: + properties: + honeywell,pmin-pascal: false + honeywell,pmax-pascal: false + +additionalProperties: false + +examples: + - | + #include + #include + i2c { + #address-cells =3D <1>; + #size-cells =3D <0>; + + pressure@18 { + compatible =3D "honeywell,abp2030pa"; + reg =3D <0x18>; + interrupt-parent =3D <&gpio3>; + interrupts =3D <21 IRQ_TYPE_EDGE_RISING>; + + honeywell,pressure-triplet =3D "001BA"; + vdd-supply =3D <&vcc_3v3>; + }; + }; + - | + spi { + #address-cells =3D <1>; + #size-cells =3D <0>; + + pressure@0 { + compatible =3D "honeywell,abp2030pa"; + reg =3D <0>; + spi-max-frequency =3D <800000>; + + honeywell,pressure-triplet =3D "001PD"; + vdd-supply =3D <&vcc_3v3>; + }; + }; +... diff --git a/MAINTAINERS b/MAINTAINERS index 31d98efb1ad1..15b92300acbc 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -11404,6 +11404,12 @@ F: lib/test_hmm* F: mm/hmm* F: tools/testing/selftests/mm/*hmm* =20 +HONEYWELL ABP2030PA PRESSURE SENSOR SERIES IIO DRIVER +M: Petre Rodan +L: linux-iio@vger.kernel.org +S: Maintained +F: Documentation/devicetree/bindings/iio/pressure/honeywell,abp2030pa.yaml + HONEYWELL HSC030PA PRESSURE SENSOR SERIES IIO DRIVER M: Petre Rodan L: linux-iio@vger.kernel.org --=20 2.51.0 From nobody Mon Dec 1 21:31:54 2025 Received: from mail.subdimension.ro (nalicastle.subdimension.ro [172.105.74.154]) (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 E5A0229E0E7; Fri, 28 Nov 2025 03:13:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=172.105.74.154 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764299641; cv=none; b=WlyM5mHjPJbm6T2Q2vbX0N2T+GJnUZfCDXm9I5Cp6S3r8rVRJIZiZsp+vdbglklyK1w2hMf1yljocf1lmCR62hEbp0S45uyd/k8yzLfPXl433lGsVEZ3IeNifjhdNjynqHDm9uMH88Q/LvQnoGUheNudgNXIdNaZzuPz0ymbJ6o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764299641; c=relaxed/simple; bh=phmdhq4xHF6buUfu9oRhHXl8v+viJpAEPVbOrA0acoo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=HShyU6U4QQkM3yw3FDOH8Fu/I72ybPKt7bviEmxDZHjGEpGCl5J2guH3CDRXBvFdITCX37wqGo6Ckh68pNDo3Czc92FNsh57erDEuDnPkvtEx2C6bdWqLYuTuApbbPP6eO5v44dysES/ueLY+7iEgmxDXr8SZTjBDLgPVI8he6w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=subdimension.ro; spf=pass smtp.mailfrom=subdimension.ro; dkim=pass (2048-bit key) header.d=subdimension.ro header.i=@subdimension.ro header.b=Zj+neGqM; arc=none smtp.client-ip=172.105.74.154 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=subdimension.ro Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=subdimension.ro Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=subdimension.ro header.i=@subdimension.ro header.b="Zj+neGqM" Received: from sunspire.home.arpa (unknown [IPv6:2a02:2f0e:3402:a400:e2d5:5eff:fed9:f1c4]) (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 1FD1016020B; Fri, 28 Nov 2025 05:13:56 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=subdimension.ro; s=mail; t=1764299636; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/1BuqTBYzXGxe2vIwjHMHyfw9KtPzmpEjOn+eL4kL/s=; b=Zj+neGqMnwgIVI1Ok/+uTR6PkMBheay44F8Nem20WaR9SZd3K49Gx64/Nluopfl890RtOc eAeB/7ge4UXBQBA2/4XYPCnmGg0aK7nuqHnNYCAdsNXTQYvNnM7HgFdcIxoQXnQSccmhiW KrUxUDVln5UDncqsKlIWZ4ghZxsEM+tnwEqb//583JykgzXym/Hl6sTxpXzTjo9rnXAmOh 3Oe0c4fZ8sABOU9hQjoydLY2xAZMIzkJQDXhHK+pNwzp7Sd7fT258417to3SaleFJh+e/1 iGzBlG4BHYF+csHlcl9OG+yse5jhSQwopacc3B80kNdOdgAFpA4NKz+w8ujEyg== From: Petre Rodan Date: Fri, 28 Nov 2025 05:13:27 +0200 Subject: [PATCH v2 2/2] iio: pressure: add Honeywell ABP2 driver Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251128-honeywell_abp2_driver-v2-2-7053748aecf7@subdimension.ro> References: <20251128-honeywell_abp2_driver-v2-0-7053748aecf7@subdimension.ro> In-Reply-To: <20251128-honeywell_abp2_driver-v2-0-7053748aecf7@subdimension.ro> To: Jonathan Cameron , David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=31860; i=petre.rodan@subdimension.ro; h=from:subject:message-id; bh=phmdhq4xHF6buUfu9oRhHXl8v+viJpAEPVbOrA0acoo=; b=LS0tLS1CRUdJTiBQR1AgTUVTU0FHRS0tLS0tCgpvd0o0bkFGdEFwTDlrQTBEQUFvQmRDc25wM k02U1dNQnl5WmlBR2twRTNDMFViTTdpeVY3SlAyTy9mRi9nckg0CmZZK0JRNEZNak9yenRiTVN4 amJqWElrQ013UUFBUW9BSFJZaEJCb2ltQncrRGJ4UXBFNmlkM1FySjZkak9rbGoKQlFKcEtSTnd BQW9KRUhRcko2ZGpPa2xqblM4UUFLc29MYnJWZUU4dHBlVlFJdWVxUU5BNnQ2YWZWV3pOM1NUZA pYVVFjdklIRDBmTXlCSnF2VnJyeTZhK1Azc0hweit4VVVOUkxWRGZJTitQTkUxN1llVUFyWi9pN mpsS21kYnYzCjMzUGsvMDMwTkNNRlFnOExJZjlpdzRLVHpiWHU4RnJZdU5sOW1zU1RicmFYWEo3 R3FuWDVJYkxGcEQzOEszMUkKaUdBSjd5MnZmaFlCNDVyN0pjZWFpWWZxUlR6dWpCT3ZIR0xaZDQ 4NWV2bW1LS2dVSG96UXpobDBkZUtabXdxOApWUEhuUDhJeDhwYVQ3SlFmOU1TaFlsblBRUzlHOW 1zb2MwbDJ3ZWhrWVdCbHc2WkFYWVg0RitQNk9OS0tycDNrCjh2OFQvS0paYXVkNDUvSllsSzBmc 1hGNFNDNEJTYWNmQ2paUEhmWlRYNGxUT3FrZVovdERrK1h0aCtPZ3ZEVzgKR0V0S2o2RFg4dlJF dlp5T2Vnc0s5VHQ2U3g2RENGWVVXTjJXUzgzWjNHemVQZjBmY1BzNThMN1BwYXY3RlMwdwo4S3R ZOHBTRXYrUVUvR1NIWWZteFN1STZxR3U1eWdLaWZVUytuL0VHUUVhYmE2dmhvVWVOenhnNzdnTV JWd3g3Ck0zeXY3V1JBM0l2M1k5NUIyLzRIT1lhZFRacEZ1WENaVldJLzdKOFlQazMxSmJLYzBhS TFSSkVoeGdVSXE0YjgKemg0VVJhbXBzS0N1TVlXMklKbmRGZDZOMVdJSGRDQ2ZQaVVlaUV5SXFQ UEhZY2E1Zm1BTkpWMCtnQ1FrZ0ZlVgpjNGcrUlY5MTJNVlQ4QllyY2h6Nk1YNkRFS2RYSld4Yi9 UdTd3QndDT1A3SlU1VzJBSFY4a1BCRUpGMWF1aTNKCld0ZTl4NHdnU2xRc1l3PT0KPW1WZjgKLS 0tLS1FTkQgUEdQIE1FU1NBR0UtLS0tLQo= X-Developer-Key: i=petre.rodan@subdimension.ro; a=openpgp; fpr=D80A7FC176151935EC3E5FA9CF269999844E7F30 Adds driver for digital Honeywell ABP2 series of board mount pressure and temperature sensors. This driver covers 113 different pressure ranges and units on both i2c and SPI buses. The communication protocol involves sending two simple commands to the sensor and there is no register access or a memory map. For this reason the regmap API was not used. The i2c address is hardcoded and depends on the part number. Optional end of conversion interrupt control is present on the i2c variants of the chips. The EOC can also be defined for the SPI variants if a non-ABP2 but compatible chip is to be driven. Tested on two different sensors. Datasheet: https://prod-edam.honeywell.com/content/dam/honeywell-edam/sps/s= iot/en-us/products/sensors/pressure-sensors/board-mount-pressure-sensors/ba= sic-abp2-series/documents/sps-siot-abp2-series-datasheet-32350268-en.pdf Signed-off-by: Petre Rodan --- v1 -> v2 commit msg: - Datasheet tag - mention the lack of regmap use Kconfig: - user can nicely select bus drivers separately abp2030pa.c: - add a few includes - blank line trimming - enum without assignments - use the recommended trailing in the arrays - less const - comment for the 5 * USEC_PER_MSEC fsleep() - curly braces for else branch - improved error codes - remove INDIO_DIRECT_MODE line - remove call to _ops->init abp2030pa.h: - add completion header - remove a few structs - rename buffer -> rx_buf in abp2_data struct - add tx_buf to abp2_data struct abp2030pa_i2c.c, abp2030pa_spi.c: - remove _init() ops - remove redundant else - remove device.h include from _spi.c @Jonathan: please comment about the rx_buf, tx_buf alignment --- MAINTAINERS | 1 + drivers/iio/pressure/Kconfig | 31 ++ drivers/iio/pressure/Makefile | 3 + drivers/iio/pressure/abp2030pa.c | 538 +++++++++++++++++++++++++++++++= ++++ drivers/iio/pressure/abp2030pa.h | 77 +++++ drivers/iio/pressure/abp2030pa_i2c.c | 87 ++++++ drivers/iio/pressure/abp2030pa_spi.c | 67 +++++ 7 files changed, 804 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 15b92300acbc..0aa9cba68137 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -11409,6 +11409,7 @@ M: Petre Rodan L: linux-iio@vger.kernel.org S: Maintained F: Documentation/devicetree/bindings/iio/pressure/honeywell,abp2030pa.yaml +F: drivers/iio/pressure/abp2030pa* =20 HONEYWELL HSC030PA PRESSURE SENSOR SERIES IIO DRIVER M: Petre Rodan diff --git a/drivers/iio/pressure/Kconfig b/drivers/iio/pressure/Kconfig index 2fe9dc90cceb..f47269f7e73c 100644 --- a/drivers/iio/pressure/Kconfig +++ b/drivers/iio/pressure/Kconfig @@ -16,6 +16,37 @@ config ABP060MG To compile this driver as a module, choose M here: the module will be called abp060mg. =20 +config ABP2030PA + tristate + +config ABP2030PA_I2C + tristate "Honeywell ABP2 pressure sensor series I2C driver" + depends on I2C + select ABP2030PA + select IIO_BUFFER + select IIO_TRIGGERED_BUFFER + help + Say Y here to build I2C bus support for the Honeywell ABP2 + series pressure and temperature digital sensor. + + To compile this driver as a module, choose M here: the module + will be called abp2030pa_i2c and you will also get abp2030pa + for the core module. + +config ABP2030PA_SPI + tristate "Honeywell ABP2 pressure sensor series SPI driver" + depends on SPI_MASTER + select ABP2030PA + select IIO_BUFFER + select IIO_TRIGGERED_BUFFER + help + Say Y here to build I2C bus support for the Honeywell ABP2 + series pressure and temperature digital sensor. + + To compile this driver as a module, choose M here: the module + will be called abp2030pa_spi and you will also get abp2030pa + for the core module. + config ROHM_BM1390 tristate "ROHM BM1390GLV-Z pressure sensor driver" depends on I2C diff --git a/drivers/iio/pressure/Makefile b/drivers/iio/pressure/Makefile index a21443e992b9..bc0d11a20acc 100644 --- a/drivers/iio/pressure/Makefile +++ b/drivers/iio/pressure/Makefile @@ -5,6 +5,9 @@ =20 # When adding new entries keep the list in alphabetical order obj-$(CONFIG_ABP060MG) +=3D abp060mg.o +obj-$(CONFIG_ABP2030PA) +=3D abp2030pa.o +obj-$(CONFIG_ABP2030PA_I2C) +=3D abp2030pa_i2c.o +obj-$(CONFIG_ABP2030PA_SPI) +=3D abp2030pa_spi.o obj-$(CONFIG_ADP810) +=3D adp810.o obj-$(CONFIG_ROHM_BM1390) +=3D rohm-bm1390.o obj-$(CONFIG_BMP280) +=3D bmp280.o diff --git a/drivers/iio/pressure/abp2030pa.c b/drivers/iio/pressure/abp203= 0pa.c new file mode 100644 index 000000000000..04a4494a74d2 --- /dev/null +++ b/drivers/iio/pressure/abp2030pa.c @@ -0,0 +1,538 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Honeywell ABP2 series pressure sensor driver + * + * Copyright (c) 2025 Petre Rodan + * + * Datasheet: https://prod-edam.honeywell.com/content/dam/honeywell-edam/s= ps/siot/en-us/products/sensors/pressure-sensors/board-mount-pressure-sensor= s/basic-abp2-series/documents/sps-siot-abp2-series-datasheet-32350268-en.pdf + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "abp2030pa.h" + +/* status byte flags */ +#define ABP2_ST_POWER BIT(6) /* 1 if device is powered */ +#define ABP2_ST_BUSY BIT(5) /* 1 if device is busy */ + +struct abp2_func_spec { + u32 output_min; + u32 output_max; +}; + +/* transfer function A: 10% to 90% of 2^24 */ +static const struct abp2_func_spec abp2_func_spec[] =3D { + [ABP2_FUNCTION_A] =3D { .output_min =3D 1677722, .output_max =3D 15099494= }, +}; + +enum abp2_variants { + ABP2001BA, ABP21_6BA, ABP22_5BA, ABP2004BA, ABP2006BA, ABP2008BA, + ABP2010BA, ABP2012BA, ABP2001BD, ABP21_6BD, ABP22_5BD, ABP2004BD, + ABP2001BG, ABP21_6BG, ABP22_5BG, ABP2004BG, ABP2006BG, ABP2008BG, + ABP2010BG, ABP2012BG, ABP2001GG, ABP21_2GG, ABP2100KA, ABP2160KA, + ABP2250KA, ABP2001KD, ABP21_6KD, ABP22_5KD, ABP2004KD, ABP2006KD, + ABP2010KD, ABP2016KD, ABP2025KD, ABP2040KD, ABP2060KD, ABP2100KD, + ABP2160KD, ABP2250KD, ABP2400KD, ABP2001KG, ABP21_6KG, ABP22_5KG, + ABP2004KG, ABP2006KG, ABP2010KG, ABP2016KG, ABP2025KG, ABP2040KG, + ABP2060KG, ABP2100KG, ABP2160KG, ABP2250KG, ABP2400KG, ABP2600KG, + ABP2800KG, ABP2250LD, ABP2600LD, ABP2600LG, ABP22_5MD, ABP2006MD, + ABP2010MD, ABP2016MD, ABP2025MD, ABP2040MD, ABP2060MD, ABP2100MD, + ABP2160MD, ABP2250MD, ABP2400MD, ABP2600MD, ABP2006MG, ABP2010MG, + ABP2016MG, ABP2025MG, ABP2040MG, ABP2060MG, ABP2100MG, ABP2160MG, + ABP2250MG, ABP2400MG, ABP2600MG, ABP2001ND, ABP2002ND, ABP2004ND, + ABP2005ND, ABP2010ND, ABP2020ND, ABP2030ND, ABP2002NG, ABP2004NG, + ABP2005NG, ABP2010NG, ABP2020NG, ABP2030NG, ABP2015PA, ABP2030PA, + ABP2060PA, ABP2100PA, ABP2150PA, ABP2175PA, ABP2001PD, ABP2005PD, + ABP2015PD, ABP2030PD, ABP2060PD, ABP2001PG, ABP2005PG, ABP2015PG, + ABP2030PG, ABP2060PG, ABP2100PG, ABP2150PG, ABP2175PG, + ABP2_VARIANTS_MAX +}; + +static const char * const abp2_triplet_variants[ABP2_VARIANTS_MAX] =3D { + [ABP2001BA] =3D "001BA", [ABP21_6BA] =3D "1.6BA", [ABP22_5BA] =3D "2.5BA", + [ABP2004BA] =3D "004BA", [ABP2006BA] =3D "006BA", [ABP2008BA] =3D "008BA", + [ABP2010BA] =3D "010BA", [ABP2012BA] =3D "012BA", [ABP2001BD] =3D "001BD", + [ABP21_6BD] =3D "1.6BD", [ABP22_5BD] =3D "2.5BD", [ABP2004BD] =3D "004BD", + [ABP2001BG] =3D "001BG", [ABP21_6BG] =3D "1.6BG", [ABP22_5BG] =3D "2.5BG", + [ABP2004BG] =3D "004BG", [ABP2006BG] =3D "006BG", [ABP2008BG] =3D "008BG", + [ABP2010BG] =3D "010BG", [ABP2012BG] =3D "012BG", [ABP2001GG] =3D "001GG", + [ABP21_2GG] =3D "1.2GG", [ABP2100KA] =3D "100KA", [ABP2160KA] =3D "160KA", + [ABP2250KA] =3D "250KA", [ABP2001KD] =3D "001KD", [ABP21_6KD] =3D "1.6KD", + [ABP22_5KD] =3D "2.5KD", [ABP2004KD] =3D "004KD", [ABP2006KD] =3D "006KD", + [ABP2010KD] =3D "010KD", [ABP2016KD] =3D "016KD", [ABP2025KD] =3D "025KD", + [ABP2040KD] =3D "040KD", [ABP2060KD] =3D "060KD", [ABP2100KD] =3D "100KD", + [ABP2160KD] =3D "160KD", [ABP2250KD] =3D "250KD", [ABP2400KD] =3D "400KD", + [ABP2001KG] =3D "001KG", [ABP21_6KG] =3D "1.6KG", [ABP22_5KG] =3D "2.5KG", + [ABP2004KG] =3D "004KG", [ABP2006KG] =3D "006KG", [ABP2010KG] =3D "010KG", + [ABP2016KG] =3D "016KG", [ABP2025KG] =3D "025KG", [ABP2040KG] =3D "040KG", + [ABP2060KG] =3D "060KG", [ABP2100KG] =3D "100KG", [ABP2160KG] =3D "160KG", + [ABP2250KG] =3D "250KG", [ABP2400KG] =3D "400KG", [ABP2600KG] =3D "600KG", + [ABP2800KG] =3D "800KG", [ABP2250LD] =3D "250LD", [ABP2600LD] =3D "600LD", + [ABP2600LG] =3D "600LG", [ABP22_5MD] =3D "2.5MD", [ABP2006MD] =3D "006MD", + [ABP2010MD] =3D "010MD", [ABP2016MD] =3D "016MD", [ABP2025MD] =3D "025MD", + [ABP2040MD] =3D "040MD", [ABP2060MD] =3D "060MD", [ABP2100MD] =3D "100MD", + [ABP2160MD] =3D "160MD", [ABP2250MD] =3D "250MD", [ABP2400MD] =3D "400MD", + [ABP2600MD] =3D "600MD", [ABP2006MG] =3D "006MG", [ABP2010MG] =3D "010MG", + [ABP2016MG] =3D "016MG", [ABP2025MG] =3D "025MG", [ABP2040MG] =3D "040MG", + [ABP2060MG] =3D "060MG", [ABP2100MG] =3D "100MG", [ABP2160MG] =3D "160MG", + [ABP2250MG] =3D "250MG", [ABP2400MG] =3D "400MG", [ABP2600MG] =3D "600MG", + [ABP2001ND] =3D "001ND", [ABP2002ND] =3D "002ND", [ABP2004ND] =3D "004ND", + [ABP2005ND] =3D "005ND", [ABP2010ND] =3D "010ND", [ABP2020ND] =3D "020ND", + [ABP2030ND] =3D "030ND", [ABP2002NG] =3D "002NG", [ABP2004NG] =3D "004NG", + [ABP2005NG] =3D "005NG", [ABP2010NG] =3D "010NG", [ABP2020NG] =3D "020NG", + [ABP2030NG] =3D "030NG", [ABP2015PA] =3D "015PA", [ABP2030PA] =3D "030PA", + [ABP2060PA] =3D "060PA", [ABP2100PA] =3D "100PA", [ABP2150PA] =3D "150PA", + [ABP2175PA] =3D "175PA", [ABP2001PD] =3D "001PD", [ABP2005PD] =3D "005PD", + [ABP2015PD] =3D "015PD", [ABP2030PD] =3D "030PD", [ABP2060PD] =3D "060PD", + [ABP2001PG] =3D "001PG", [ABP2005PG] =3D "005PG", [ABP2015PG] =3D "015PG", + [ABP2030PG] =3D "030PG", [ABP2060PG] =3D "060PG", [ABP2100PG] =3D "100PG", + [ABP2150PG] =3D "150PG", [ABP2175PG] =3D "175PG", +}; + +/** + * struct abp2_range_config - list of pressure ranges based on nomenclature + * @pmin: lowest pressure that can be measured + * @pmax: highest pressure that can be measured + */ +struct abp2_range_config { + s32 pmin; + s32 pmax; +}; + +/* All min max limits have been converted to pascals */ +static const struct abp2_range_config abp2_range_config[ABP2_VARIANTS_MAX]= =3D { + [ABP2001BA] =3D { .pmin =3D 0, .pmax =3D 100000 }, + [ABP21_6BA] =3D { .pmin =3D 0, .pmax =3D 160000 }, + [ABP22_5BA] =3D { .pmin =3D 0, .pmax =3D 250000 }, + [ABP2004BA] =3D { .pmin =3D 0, .pmax =3D 400000 }, + [ABP2006BA] =3D { .pmin =3D 0, .pmax =3D 600000 }, + [ABP2008BA] =3D { .pmin =3D 0, .pmax =3D 800000 }, + [ABP2010BA] =3D { .pmin =3D 0, .pmax =3D 1000000 }, + [ABP2012BA] =3D { .pmin =3D 0, .pmax =3D 1200000 }, + [ABP2001BD] =3D { .pmin =3D -100000, .pmax =3D 100000 }, + [ABP21_6BD] =3D { .pmin =3D -160000, .pmax =3D 160000 }, + [ABP22_5BD] =3D { .pmin =3D -250000, .pmax =3D 250000 }, + [ABP2004BD] =3D { .pmin =3D -400000, .pmax =3D 400000 }, + [ABP2001BG] =3D { .pmin =3D 0, .pmax =3D 100000 }, + [ABP21_6BG] =3D { .pmin =3D 0, .pmax =3D 160000 }, + [ABP22_5BG] =3D { .pmin =3D 0, .pmax =3D 250000 }, + [ABP2004BG] =3D { .pmin =3D 0, .pmax =3D 400000 }, + [ABP2006BG] =3D { .pmin =3D 0, .pmax =3D 600000 }, + [ABP2008BG] =3D { .pmin =3D 0, .pmax =3D 800000 }, + [ABP2010BG] =3D { .pmin =3D 0, .pmax =3D 1000000 }, + [ABP2012BG] =3D { .pmin =3D 0, .pmax =3D 1200000 }, + [ABP2001GG] =3D { .pmin =3D 0, .pmax =3D 1000000 }, + [ABP21_2GG] =3D { .pmin =3D 0, .pmax =3D 1200000 }, + [ABP2100KA] =3D { .pmin =3D 0, .pmax =3D 100000 }, + [ABP2160KA] =3D { .pmin =3D 0, .pmax =3D 160000 }, + [ABP2250KA] =3D { .pmin =3D 0, .pmax =3D 250000 }, + [ABP2001KD] =3D { .pmin =3D -1000, .pmax =3D 1000 }, + [ABP21_6KD] =3D { .pmin =3D -1600, .pmax =3D 1600 }, + [ABP22_5KD] =3D { .pmin =3D -2500, .pmax =3D 2500 }, + [ABP2004KD] =3D { .pmin =3D -4000, .pmax =3D 4000 }, + [ABP2006KD] =3D { .pmin =3D -6000, .pmax =3D 6000 }, + [ABP2010KD] =3D { .pmin =3D -10000, .pmax =3D 10000 }, + [ABP2016KD] =3D { .pmin =3D -16000, .pmax =3D 16000 }, + [ABP2025KD] =3D { .pmin =3D -25000, .pmax =3D 25000 }, + [ABP2040KD] =3D { .pmin =3D -40000, .pmax =3D 40000 }, + [ABP2060KD] =3D { .pmin =3D -60000, .pmax =3D 60000 }, + [ABP2100KD] =3D { .pmin =3D -100000, .pmax =3D 100000 }, + [ABP2160KD] =3D { .pmin =3D -160000, .pmax =3D 160000 }, + [ABP2250KD] =3D { .pmin =3D -250000, .pmax =3D 250000 }, + [ABP2400KD] =3D { .pmin =3D -400000, .pmax =3D 400000 }, + [ABP2001KG] =3D { .pmin =3D 0, .pmax =3D 1000 }, + [ABP21_6KG] =3D { .pmin =3D 0, .pmax =3D 1600 }, + [ABP22_5KG] =3D { .pmin =3D 0, .pmax =3D 2500 }, + [ABP2004KG] =3D { .pmin =3D 0, .pmax =3D 4000 }, + [ABP2006KG] =3D { .pmin =3D 0, .pmax =3D 6000 }, + [ABP2010KG] =3D { .pmin =3D 0, .pmax =3D 10000 }, + [ABP2016KG] =3D { .pmin =3D 0, .pmax =3D 16000 }, + [ABP2025KG] =3D { .pmin =3D 0, .pmax =3D 25000 }, + [ABP2040KG] =3D { .pmin =3D 0, .pmax =3D 40000 }, + [ABP2060KG] =3D { .pmin =3D 0, .pmax =3D 60000 }, + [ABP2100KG] =3D { .pmin =3D 0, .pmax =3D 100000 }, + [ABP2160KG] =3D { .pmin =3D 0, .pmax =3D 160000 }, + [ABP2250KG] =3D { .pmin =3D 0, .pmax =3D 250000 }, + [ABP2400KG] =3D { .pmin =3D 0, .pmax =3D 400000 }, + [ABP2600KG] =3D { .pmin =3D 0, .pmax =3D 600000 }, + [ABP2800KG] =3D { .pmin =3D 0, .pmax =3D 800000 }, + [ABP2250LD] =3D { .pmin =3D -250, .pmax =3D 250 }, + [ABP2600LD] =3D { .pmin =3D -600, .pmax =3D 600 }, + [ABP2600LG] =3D { .pmin =3D 0, .pmax =3D 600 }, + [ABP22_5MD] =3D { .pmin =3D -250, .pmax =3D 250 }, + [ABP2006MD] =3D { .pmin =3D -600, .pmax =3D 600 }, + [ABP2010MD] =3D { .pmin =3D -1000, .pmax =3D 1000 }, + [ABP2016MD] =3D { .pmin =3D -1600, .pmax =3D 1600 }, + [ABP2025MD] =3D { .pmin =3D -2500, .pmax =3D 2500 }, + [ABP2040MD] =3D { .pmin =3D -4000, .pmax =3D 4000 }, + [ABP2060MD] =3D { .pmin =3D -6000, .pmax =3D 6000 }, + [ABP2100MD] =3D { .pmin =3D -10000, .pmax =3D 10000 }, + [ABP2160MD] =3D { .pmin =3D -16000, .pmax =3D 16000 }, + [ABP2250MD] =3D { .pmin =3D -25000, .pmax =3D 25000 }, + [ABP2400MD] =3D { .pmin =3D -40000, .pmax =3D 40000 }, + [ABP2600MD] =3D { .pmin =3D -60000, .pmax =3D 60000 }, + [ABP2006MG] =3D { .pmin =3D 0, .pmax =3D 600 }, + [ABP2010MG] =3D { .pmin =3D 0, .pmax =3D 1000 }, + [ABP2016MG] =3D { .pmin =3D 0, .pmax =3D 1600 }, + [ABP2025MG] =3D { .pmin =3D 0, .pmax =3D 2500 }, + [ABP2040MG] =3D { .pmin =3D 0, .pmax =3D 4000 }, + [ABP2060MG] =3D { .pmin =3D 0, .pmax =3D 6000 }, + [ABP2100MG] =3D { .pmin =3D 0, .pmax =3D 10000 }, + [ABP2160MG] =3D { .pmin =3D 0, .pmax =3D 16000 }, + [ABP2250MG] =3D { .pmin =3D 0, .pmax =3D 25000 }, + [ABP2400MG] =3D { .pmin =3D 0, .pmax =3D 40000 }, + [ABP2600MG] =3D { .pmin =3D 0, .pmax =3D 60000 }, + [ABP2001ND] =3D { .pmin =3D -249, .pmax =3D 249 }, + [ABP2002ND] =3D { .pmin =3D -498, .pmax =3D 498 }, + [ABP2004ND] =3D { .pmin =3D -996, .pmax =3D 996 }, + [ABP2005ND] =3D { .pmin =3D -1245, .pmax =3D 1245 }, + [ABP2010ND] =3D { .pmin =3D -2491, .pmax =3D 2491 }, + [ABP2020ND] =3D { .pmin =3D -4982, .pmax =3D 4982 }, + [ABP2030ND] =3D { .pmin =3D -7473, .pmax =3D 7473 }, + [ABP2002NG] =3D { .pmin =3D 0, .pmax =3D 498 }, + [ABP2004NG] =3D { .pmin =3D 0, .pmax =3D 996 }, + [ABP2005NG] =3D { .pmin =3D 0, .pmax =3D 1245 }, + [ABP2010NG] =3D { .pmin =3D 0, .pmax =3D 2491 }, + [ABP2020NG] =3D { .pmin =3D 0, .pmax =3D 4982 }, + [ABP2030NG] =3D { .pmin =3D 0, .pmax =3D 7473 }, + [ABP2015PA] =3D { .pmin =3D 0, .pmax =3D 103421 }, + [ABP2030PA] =3D { .pmin =3D 0, .pmax =3D 206843 }, + [ABP2060PA] =3D { .pmin =3D 0, .pmax =3D 413685 }, + [ABP2100PA] =3D { .pmin =3D 0, .pmax =3D 689476 }, + [ABP2150PA] =3D { .pmin =3D 0, .pmax =3D 1034214 }, + [ABP2175PA] =3D { .pmin =3D 0, .pmax =3D 1206583 }, + [ABP2001PD] =3D { .pmin =3D -6895, .pmax =3D 6895 }, + [ABP2005PD] =3D { .pmin =3D -34474, .pmax =3D 34474 }, + [ABP2015PD] =3D { .pmin =3D -103421, .pmax =3D 103421 }, + [ABP2030PD] =3D { .pmin =3D -206843, .pmax =3D 206843 }, + [ABP2060PD] =3D { .pmin =3D -413685, .pmax =3D 413685 }, + [ABP2001PG] =3D { .pmin =3D 0, .pmax =3D 6895 }, + [ABP2005PG] =3D { .pmin =3D 0, .pmax =3D 34474 }, + [ABP2015PG] =3D { .pmin =3D 0, .pmax =3D 103421 }, + [ABP2030PG] =3D { .pmin =3D 0, .pmax =3D 206843 }, + [ABP2060PG] =3D { .pmin =3D 0, .pmax =3D 413685 }, + [ABP2100PG] =3D { .pmin =3D 0, .pmax =3D 689476 }, + [ABP2150PG] =3D { .pmin =3D 0, .pmax =3D 1034214 }, + [ABP2175PG] =3D { .pmin =3D 0, .pmax =3D 1206583 }, +}; + +static int abp2_get_measurement(struct abp2_data *data) +{ + struct device *dev =3D data->dev; + int ret; + + memset(data->rx_buf, 0, sizeof(data->rx_buf)); + reinit_completion(&data->completion); + + ret =3D data->ops->write(data, ABP2_CMD_SYNC, ABP2_PKT_SYNC_LEN); + if (ret < 0) + return ret; + + /* + * either use the EOC interrupt if it was enabled or + * wait 5ms for the conversion + */ + if (data->irq > 0) { + ret =3D wait_for_completion_timeout(&data->completion, HZ); + if (!ret) { + dev_err(dev, "timeout waiting for EOC interrupt\n"); + return -ETIMEDOUT; + } + } else { + fsleep(5 * USEC_PER_MSEC); + } + + ret =3D data->ops->read(data, ABP2_CMD_NOP, ABP2_PKT_NOP_LEN); + if (ret < 0) + return ret; + + /* + * status byte flags + * bit7 SANITY_CHK - must always be 0 + * bit6 ABP2_ST_POWER - 1 if device is powered + * bit5 ABP2_ST_BUSY - 1 if device has no new conversion ready + * bit4 SANITY_CHK - must always be 0 + * bit3 SANITY_CHK - must always be 0 + * bit2 MEMORY_ERR - 1 if integrity test has failed + * bit1 SANITY_CHK - must always be 0 + * bit0 MATH_ERR - 1 during internal math saturation err + */ + + if (data->rx_buf[0] =3D=3D (ABP2_ST_POWER | ABP2_ST_BUSY)) + return -EBUSY; + + if (data->rx_buf[0] !=3D ABP2_ST_POWER) { + dev_err(data->dev, + "unexpected status byte 0x%02x\n", data->rx_buf[0]); + return -EIO; + } + + return 0; +} + +static irqreturn_t abp2_eoc_handler(int irq, void *private) +{ + struct abp2_data *data =3D private; + + complete(&data->completion); + + return IRQ_HANDLED; +} + +static irqreturn_t abp2_trigger_handler(int irq, void *private) +{ + int ret; + struct iio_poll_func *pf =3D private; + struct iio_dev *indio_dev =3D pf->indio_dev; + struct abp2_data *data =3D iio_priv(indio_dev); + + ret =3D abp2_get_measurement(data); + if (ret < 0) + goto err; + + data->scan.chan[0] =3D get_unaligned_be24(&data->rx_buf[1]); + data->scan.chan[1] =3D get_unaligned_be24(&data->rx_buf[4]); + + iio_push_to_buffers_with_ts(indio_dev, &data->scan, sizeof(data->scan), + iio_get_time_ns(indio_dev)); + +err: + iio_trigger_notify_done(indio_dev->trig); + + return IRQ_HANDLED; +} + +/* + * IIO ABI expects + * value =3D (conv + offset) * scale + * + * datasheet provides the following formula for determining the temperature + * temp[C] =3D conv * a + b + * where a =3D 200/16777215; b =3D -50 + * + * temp[C] =3D (conv + (b/a)) * a * (1000) + * =3D> + * scale =3D a * 1000 =3D .0000119209296 * 1000 =3D .01192092966562 + * offset =3D b/a =3D -50 * 16777215 / 200 =3D -4194303.75 + * + * based on the datasheet + * pressure =3D (conv - Omin) * Q + Pmin =3D + * ((conv - Omin) + Pmin/Q) * Q + * =3D> + * scale =3D Q =3D (Pmax - Pmin) / (Omax - Omin) + * offset =3D Pmin/Q - Omin =3D Pmin * (Omax - Omin) / (Pmax - Pmin) - Om= in + */ +static int abp2_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *channel, int *val, + int *val2, long mask) +{ + struct abp2_data *data =3D iio_priv(indio_dev); + int ret; + + switch (mask) { + case IIO_CHAN_INFO_RAW: + ret =3D abp2_get_measurement(data); + if (ret < 0) + return ret; + + switch (channel->type) { + case IIO_PRESSURE: + *val =3D get_unaligned_be24(&data->rx_buf[1]); + return IIO_VAL_INT; + case IIO_TEMP: + *val =3D get_unaligned_be24(&data->rx_buf[4]); + return IIO_VAL_INT; + default: + return -EINVAL; + } + return IIO_VAL_INT; + + case IIO_CHAN_INFO_SCALE: + switch (channel->type) { + case IIO_TEMP: + *val =3D 0; + *val2 =3D 11920929; + return IIO_VAL_INT_PLUS_NANO; + case IIO_PRESSURE: + *val =3D data->p_scale; + *val2 =3D data->p_scale_dec; + return IIO_VAL_INT_PLUS_NANO; + default: + return -EINVAL; + } + + case IIO_CHAN_INFO_OFFSET: + switch (channel->type) { + case IIO_TEMP: + *val =3D -4194304; + return IIO_VAL_INT; + case IIO_PRESSURE: + *val =3D data->p_offset; + return IIO_VAL_INT; + default: + return -EINVAL; + } + + default: + return -EINVAL; + } +} + +static const struct iio_info abp2_info =3D { + .read_raw =3D &abp2_read_raw, +}; + +static const struct iio_chan_spec abp2_channels[] =3D { + { + .type =3D IIO_PRESSURE, + .info_mask_separate =3D BIT(IIO_CHAN_INFO_RAW) | + BIT(IIO_CHAN_INFO_SCALE) | + BIT(IIO_CHAN_INFO_OFFSET), + .scan_index =3D 0, + .scan_type =3D { + .sign =3D 'u', + .realbits =3D 24, + .storagebits =3D 32, + .endianness =3D IIO_CPU, + }, + }, + { + .type =3D IIO_TEMP, + .info_mask_separate =3D BIT(IIO_CHAN_INFO_RAW) | + BIT(IIO_CHAN_INFO_SCALE) | + BIT(IIO_CHAN_INFO_OFFSET), + .scan_index =3D 1, + .scan_type =3D { + .sign =3D 'u', + .realbits =3D 24, + .storagebits =3D 32, + .endianness =3D IIO_CPU, + }, + }, + IIO_CHAN_SOFT_TIMESTAMP(2), +}; + +int abp2_common_probe(struct device *dev, const struct abp2_ops *ops, int = irq) +{ + int ret; + struct abp2_data *data; + struct iio_dev *indio_dev; + const char *triplet; + s64 tmp; + + indio_dev =3D devm_iio_device_alloc(dev, sizeof(*data)); + if (!indio_dev) + return -ENOMEM; + + data =3D iio_priv(indio_dev); + data->dev =3D dev; + data->ops =3D ops; + data->irq =3D irq; + + init_completion(&data->completion); + + indio_dev->name =3D "abp2030pa"; + indio_dev->info =3D &abp2_info; + indio_dev->channels =3D abp2_channels; + indio_dev->num_channels =3D ARRAY_SIZE(abp2_channels); + + ret =3D devm_regulator_get_enable(dev, "vdd"); + if (ret) + return dev_err_probe(dev, ret, + "can't get and enable vdd supply\n"); + + ret =3D device_property_read_string(dev, "honeywell,pressure-triplet", + &triplet); + if (ret) { + ret =3D device_property_read_u32(dev, "honeywell,pmin-pascal", + &data->pmin); + if (ret) + return dev_err_probe(dev, ret, + "honeywell,pmin-pascal could not be read\n"); + + ret =3D 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 =3D device_property_match_property_string(dev, + "honeywell,pressure-triplet", + abp2_triplet_variants, + ABP2_VARIANTS_MAX); + if (ret < 0) + return dev_err_probe(dev, -EINVAL, + "honeywell,pressure-triplet is invalid\n"); + + data->pmin =3D abp2_range_config[ret].pmin; + data->pmax =3D abp2_range_config[ret].pmax; + } + + if (data->pmin >=3D data->pmax) + return dev_err_probe(dev, -EINVAL, + "pressure limits are invalid\n"); + + data->outmin =3D abp2_func_spec[data->function].output_min; + data->outmax =3D abp2_func_spec[data->function].output_max; + + tmp =3D div_s64(((s64)(data->pmax - data->pmin)) * NANO, + data->outmax - data->outmin); + data->p_scale =3D div_s64_rem(tmp, NANO, &data->p_scale_dec); + + tmp =3D div_s64((s64)data->pmin * (s64)(data->outmax - data->outmin), + (s64)(data->pmax - data->pmin)) - (s64)(data->outmin); + data->p_offset =3D tmp; + + if (data->irq > 0) { + ret =3D devm_request_irq(dev, data->irq, abp2_eoc_handler, + IRQF_TRIGGER_RISING, + dev_name(dev), + data); + if (ret) + return dev_err_probe(dev, ret, + "request irq %d failed\n", data->irq); + } + + ret =3D devm_iio_triggered_buffer_setup(dev, indio_dev, NULL, + abp2_trigger_handler, NULL); + if (ret) + return dev_err_probe(dev, ret, + "iio triggered buffer setup failed\n"); + + ret =3D devm_iio_device_register(dev, indio_dev); + if (ret) + return dev_err_probe(dev, ret, + "unable to register iio device\n"); + + return 0; +} +EXPORT_SYMBOL_NS_GPL(abp2_common_probe, "IIO_HONEYWELL_ABP2030PA"); + +MODULE_AUTHOR("Petre Rodan "); +MODULE_DESCRIPTION("Honeywell ABP2 pressure sensor core driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/iio/pressure/abp2030pa.h b/drivers/iio/pressure/abp203= 0pa.h new file mode 100644 index 000000000000..5c1de390dbdd --- /dev/null +++ b/drivers/iio/pressure/abp2030pa.h @@ -0,0 +1,77 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Honeywell ABP2 series pressure sensor driver + * + * Copyright (c) 2025 Petre Rodan + */ + +#ifndef _ABP2030PA_H +#define _ABP2030PA_H + +#include +#include + +#include + +#define ABP2_MEASUREMENT_RD_SIZE 7 +#define ABP2_CMD_NOP 0xf0 +#define ABP2_CMD_SYNC 0xaa +#define ABP2_PKT_NOP_LEN ABP2_MEASUREMENT_RD_SIZE +#define ABP2_PKT_SYNC_LEN 3 + +struct device; + +struct abp2_data; +struct abp2_ops; + +enum abp2_func_id { + ABP2_FUNCTION_A, +}; + +/** + * struct abp2_data + * @dev: current device structure + * @ops: pointers for bus specific read and write functions + * @pmin: minimal pressure in pascal + * @pmax: maximal pressure in pascal + * @outmin: minimum raw pressure in counts (based on transfer function) + * @outmax: maximum raw pressure in counts (based on transfer function) + * @function: transfer function + * @p_scale: pressure scale + * @p_scale_dec: pressure scale, decimal number + * @p_offset: pressure offset + * @irq: end of conversion - applies only to the i2c sensor + * @completion: handshake from irq to read + * @scan: channel values for buffered mode + * @tx_buf: transmit buffer used during the SPI communication + * @rx_buf: raw data provided by sensor + */ +struct abp2_data { + struct device *dev; + const struct abp2_ops *ops; + s32 pmin; + s32 pmax; + u32 outmin; + u32 outmax; + enum abp2_func_id function; + int p_scale; + int p_scale_dec; + int p_offset; + int irq; + struct completion completion; + struct { + u32 chan[2]; + aligned_s64 timestamp; + } scan; + u8 tx_buf[ABP2_MEASUREMENT_RD_SIZE] __aligned(IIO_DMA_MINALIGN); + u8 rx_buf[ABP2_MEASUREMENT_RD_SIZE] __aligned(IIO_DMA_MINALIGN); +}; + +struct abp2_ops { + int (*read)(struct abp2_data *data, u8 cmd, u8 nbytes); + int (*write)(struct abp2_data *data, u8 cmd, u8 nbytes); +}; + +int abp2_common_probe(struct device *dev, const struct abp2_ops *ops, int = irq); + +#endif diff --git a/drivers/iio/pressure/abp2030pa_i2c.c b/drivers/iio/pressure/ab= p2030pa_i2c.c new file mode 100644 index 000000000000..f29a5494869c --- /dev/null +++ b/drivers/iio/pressure/abp2030pa_i2c.c @@ -0,0 +1,87 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Honeywell ABP2 series pressure sensor driver + * + * Copyright (c) 2025 Petre Rodan + */ + +#include +#include +#include +#include +#include +#include + +#include "abp2030pa.h" + +static int abp2_i2c_read(struct abp2_data *data, u8 unused, u8 nbytes) +{ + struct i2c_client *client =3D to_i2c_client(data->dev); + int ret; + + if (nbytes > ABP2_MEASUREMENT_RD_SIZE) + return -EOVERFLOW; + + ret =3D i2c_master_recv(client, data->rx_buf, nbytes); + if (ret < 0) + return ret; + if (ret !=3D nbytes) + return -EIO; + + return 0; +} + +static int abp2_i2c_write(struct abp2_data *data, u8 cmd, u8 unused) +{ + struct i2c_client *client =3D to_i2c_client(data->dev); + u8 wdata[ABP2_PKT_SYNC_LEN] =3D { cmd }; + int ret; + + ret =3D i2c_master_send(client, wdata, ABP2_PKT_SYNC_LEN); + if (ret < 0) + return ret; + if (ret !=3D ABP2_PKT_SYNC_LEN) + return -EIO; + + return 0; +} + +static const struct abp2_ops abp2_i2c_ops =3D { + .read =3D abp2_i2c_read, + .write =3D abp2_i2c_write, +}; + +static int abp2_i2c_probe(struct i2c_client *client) +{ + if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) + return -EOPNOTSUPP; + + return abp2_common_probe(&client->dev, &abp2_i2c_ops, client->irq); +} + +static const struct of_device_id abp2_i2c_match[] =3D { + { .compatible =3D "honeywell,abp2030pa" }, + { } +}; +MODULE_DEVICE_TABLE(of, abp2_i2c_match); + +static const struct i2c_device_id abp2_i2c_id[] =3D { + { "abp2030pa" }, + { } +}; +MODULE_DEVICE_TABLE(i2c, abp2_i2c_id); + +static struct i2c_driver abp2_i2c_driver =3D { + .driver =3D { + .name =3D "abp2030pa", + .of_match_table =3D abp2_i2c_match, + }, + .probe =3D abp2_i2c_probe, + .id_table =3D abp2_i2c_id, +}; +module_i2c_driver(abp2_i2c_driver); + +MODULE_AUTHOR("Petre Rodan "); +MODULE_DESCRIPTION("Honeywell ABP2 pressure sensor i2c driver"); +MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS("IIO_HONEYWELL_ABP2030PA"); diff --git a/drivers/iio/pressure/abp2030pa_spi.c b/drivers/iio/pressure/ab= p2030pa_spi.c new file mode 100644 index 000000000000..924fcb2fb690 --- /dev/null +++ b/drivers/iio/pressure/abp2030pa_spi.c @@ -0,0 +1,67 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Honeywell ABP2 series pressure sensor driver + * + * Copyright (c) 2025 Petre Rodan + */ + +#include +#include +#include +#include +#include + +#include "abp2030pa.h" + +static int abp2_spi_xfer(struct abp2_data *data, u8 cmd, u8 nbytes) +{ + struct spi_device *spi =3D to_spi_device(data->dev); + struct spi_transfer xfer; + + if (nbytes > ABP2_MEASUREMENT_RD_SIZE) + return -EOVERFLOW; + + data->tx_buf[0] =3D cmd; + xfer.tx_buf =3D data->tx_buf; + xfer.rx_buf =3D data->rx_buf; + xfer.len =3D nbytes; + + return spi_sync_transfer(spi, &xfer, 1); +} + +static const struct abp2_ops abp2_spi_ops =3D { + .read =3D abp2_spi_xfer, + .write =3D abp2_spi_xfer, +}; + +static int abp2_spi_probe(struct spi_device *spi) +{ + return abp2_common_probe(&spi->dev, &abp2_spi_ops, spi->irq); +} + +static const struct of_device_id abp2_spi_match[] =3D { + { .compatible =3D "honeywell,abp2030pa" }, + { } +}; +MODULE_DEVICE_TABLE(of, abp2_spi_match); + +static const struct spi_device_id abp2_spi_id[] =3D { + { "abp2030pa" }, + { } +}; +MODULE_DEVICE_TABLE(spi, abp2_spi_id); + +static struct spi_driver abp2_spi_driver =3D { + .driver =3D { + .name =3D "abp2030pa", + .of_match_table =3D abp2_spi_match, + }, + .probe =3D abp2_spi_probe, + .id_table =3D abp2_spi_id, +}; +module_spi_driver(abp2_spi_driver); + +MODULE_AUTHOR("Petre Rodan "); +MODULE_DESCRIPTION("Honeywell ABP2 pressure sensor spi driver"); +MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS("IIO_HONEYWELL_ABP2030PA"); --=20 2.51.0