From nobody Mon Dec 1 23:33:39 2025 Received: from mail-pj1-f65.google.com (mail-pj1-f65.google.com [209.85.216.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B38292F3635 for ; Wed, 26 Nov 2025 03:18:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.65 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764127093; cv=none; b=th5AFtH4Peu2z4yu65x+oZEFYDcq4DzjDekgzhSsZ2LaplrHl2taZFBzYUKpWbj+6OgiFa6eM9sKYCRerrkd2hTRyLQmt2E9j/Zdg/8OdzBmFDfzozFiiIKuV9DAE/06urUl85xtaTU3GsqrCimyvUXxaqJ0e4hqIaOnZLVii4g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764127093; c=relaxed/simple; bh=mFGAf05gZ2JpMz8sAbnQz9cmri70ARBRr6x45PxpHvs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oGeati4Y2KS1R2za0EIaxfeLGc3qRJcw6H/XWVACzINHFHYq+OrjVJ2908rnla4qMA2EY2Snkn5l7ucQ7QOhN5NCNfbPcmM14MA2cLJwCSJOj5Ix+ZUC11YRK27y9bIkr+5ppBYaVML92/AY3kOVMzIfIu91DM2Z5Y8uAz8LANw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=dgvjoXGp; arc=none smtp.client-ip=209.85.216.65 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dgvjoXGp" Received: by mail-pj1-f65.google.com with SMTP id 98e67ed59e1d1-343f35d0f99so5121265a91.0 for ; Tue, 25 Nov 2025 19:18:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764127091; x=1764731891; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pJ7IKj64Qr0OZ0iruuUqcxkX7/QCGnNK4nFSticAN6I=; b=dgvjoXGpLfKN29V0UYDxR8nsUL7kliwfTG4HubLHnSVwqsEqa06rp9ASIu8wuCgPvt KEGNxsmEqsm+qAvZAu/lim0+jg4J/bX4ElYLsoo3OgvousPzPhN80DE2g03pa3FcAJoX jaraBmJ853zJ3hqq4kGYIHONm6bTc4sMfPBiNoYtnjx9AUFWzKU3vibsVjKDMwniJ1iX w8/o/iS6gscMy2RY2Y83k9j1RQG9LYC9sD1FeUzuKu2l/+yZdWZqOEt1TnYQQ/brkpjS YElZzmaT0YUV9jlvspBaDROSzr0Ufa/0Fzr/j/xiGRQUNJA/UVWEKgTSdcWcRnCdL199 XDcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764127091; x=1764731891; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=pJ7IKj64Qr0OZ0iruuUqcxkX7/QCGnNK4nFSticAN6I=; b=vI5mvkY8hzvYcPOlxv6EpJVTHCi9lIk9YnJ5cAZ1jwWOCJXyAP6UnbMaohBKQ+398l dvjQIGl4yKFOcVGqUQ3mlADyvSAdr0J+frAp3sdyIt6tLbWEhA7cZs0neIKzXgpms4oX MiR/mv/mbgdge4aP/DBIGgKw4FaRipxhB+beHuQL7pEF3JaiCW0nF9fGLpvMq8nKPnfD Jc13QYQ7AremSUcDxPXgAhoPG1xtCCqs4u3K+AVObMIP1hpP9HhqW3lZmCo/C4fo4Vtr /ztuFHB5RSnX+ZrMVTjlmJ5Quwoj6P62sugZMFu6n19B1foJyz5/MwlMF60xfI1ZFVW7 jDRw== X-Forwarded-Encrypted: i=1; AJvYcCVtjDDRKkOf68rkYlokNaIDpbdtGrI3ZjbNOI6y9Ibv4S+6Zg0rttYK8h2Olp7mibj6j435eAaFDQk716Q=@vger.kernel.org X-Gm-Message-State: AOJu0YyEB8vkmF0PlzKW/UwJeXhzMt+3I5RuR6gAxNYQuEwnwcpOUhTZ E5pbaD2Y0WlWpvvoHT2c0XcpryYeLsOo5FGODFetKeZfJb9ze+rgTHjw X-Gm-Gg: ASbGncv4eHnpv4aaGLseOvUhV3G0a8Kmx7gVQ+4nxEEoPBPRO9EoOC5+RmJ8gBx0TXI mZQl50wNn6zavla0JGpoJEMPZAJfjQmDS7Q1Ju5FUT0tAPRF32Anq7cEmd5WMr9vYx9Fv/dkJrq REdrnPo/zrWcGWOO0XnYJ77JuW0Sw8kM/gKxjQiB8I3te3TZ8Zo8+53MBNygdjVvnMPjDDR4XNM 39YLFSCkoNlor2qtcnx1ApYqqYEs4jHmAhFjewU20PlETgmh4quaMpOH8tvCrEstluVD67YyrDj CgF2r1CjRbhz0fMT6qSRbyVmJWwE4nuNuoQveTtMb6QFoOOV4hAJ+9wkEprd0pvsYMq0I7R5eXU TS62Tc4pD+mlTq5nuoxtX5Cf0PTjdgcrTGAcrwU1Q2P1kISkBXQ9QHU0P3KnYQ5AmK5EFTb/zEK LjprOm0mXmA/4NETkmKgsxeXCF X-Google-Smtp-Source: AGHT+IGa1FJoKpUswR5UD+dOiC7H4W7Ds1tZvtbxBdOuvihTQsXPDXj1wGT1F6VG0QJz4aBP57V84A== X-Received: by 2002:a17:90b:384c:b0:33e:2934:6e11 with SMTP id 98e67ed59e1d1-3475ebf9acamr4279517a91.11.1764127090901; Tue, 25 Nov 2025 19:18:10 -0800 (PST) Received: from Ubuntu24.. ([103.187.64.30]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-bd760ac62ecsm17935713a12.26.2025.11.25.19.18.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Nov 2025 19:18:10 -0800 (PST) From: Shrikant Raskar To: jic23@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org Cc: dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org, heiko@sntech.de, neil.armstrong@linaro.org, skhan@linuxfoundation.org, david.hunter.linux@gmail.com, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Shrikant Raskar Subject: [PATCH 1/3] dt-bindings: iio: proximity: Add YAML binding for RFD77402 ToF sensor Date: Wed, 26 Nov 2025 08:44:38 +0530 Message-ID: <20251126031440.30065-2-raskar.shree97@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251126031440.30065-1-raskar.shree97@gmail.com> References: <20251126031440.30065-1-raskar.shree97@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The RFD77402 driver has existed without a formal device tree binding description. With the recent addition of Device Tree support and interrupt handling in the driver, it is now necessary to document the DT properties used for configuring the device. Since the binding introduces the compatible string "rfdigital,rfd77402", the "rfdigital" vendor prefix is also added to vendor-prefixes.yaml. Signed-off-by: Shrikant Raskar --- .../iio/proximity/rfdigital,rfd77402.yaml | 55 +++++++++++++++++++ .../devicetree/bindings/vendor-prefixes.yaml | 2 + 2 files changed, 57 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/proximity/rfdigit= al,rfd77402.yaml diff --git a/Documentation/devicetree/bindings/iio/proximity/rfdigital,rfd7= 7402.yaml b/Documentation/devicetree/bindings/iio/proximity/rfdigital,rfd77= 402.yaml new file mode 100644 index 000000000000..93deaa4e8b7a --- /dev/null +++ b/Documentation/devicetree/bindings/iio/proximity/rfdigital,rfd77402.ya= ml @@ -0,0 +1,55 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/proximity/rfdigital,rfd77402.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: RF Digital RFD77402 ToF sensor + +maintainers: + - Shrikant Raskar + +description: | + The RF Digital RFD77402 is a Time-of-Flight (ToF) proximity and distance + sensor providing up to 200 mm range measurement over an I2C interface. + +properties: + compatible: + const: rfdigital,rfd77402 + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + description: | + Generated by the device to announce that a new + measurement data is ready in result register. + + vdd-supply: + description: Regulator that provides power to the sensor + + vddio-supply: + description: Regulator providing I/O interface voltage + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + #include + i2c { + #address-cells =3D <1>; + #size-cells =3D <0>; + + proximity@4c { + compatible =3D "rfdigital,rfd77402"; + reg =3D <0x4c>; + interrupt-parent =3D <&gpio>; + interrupts =3D <4 IRQ_TYPE_EDGE_FALLING>; + }; + }; +... diff --git a/Documentation/devicetree/bindings/vendor-prefixes.yaml b/Docum= entation/devicetree/bindings/vendor-prefixes.yaml index f1d1882009ba..a2e113e29e37 100644 --- a/Documentation/devicetree/bindings/vendor-prefixes.yaml +++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml @@ -1341,6 +1341,8 @@ patternProperties: description: Revolution Robotics, Inc. (Revotics) "^rex,.*": description: iMX6 Rex Project + "^rfdigital,.*": + description: RF Digital Corporation "^richtek,.*": description: Richtek Technology Corporation "^ricoh,.*": --=20 2.43.0 From nobody Mon Dec 1 23:33:39 2025 Received: from mail-pf1-f193.google.com (mail-pf1-f193.google.com [209.85.210.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4189B2FDC30 for ; Wed, 26 Nov 2025 03:18:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.193 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764127102; cv=none; b=mOnXDDHodWnzjMeMarEUQkYyboXgAuYnB0Pv9ltd4ZaE74m0/1cl6UMsw+MGGrQkoSEFG0dlLADlX33SwdMI/RvHeVv3q9eaiX94gDNGDgucSQm/zYcKSjMYD/L+0eEUBI5EehV7YzJv8rbBpptY6m2hVjXxjN7POEPQbeaixNM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764127102; c=relaxed/simple; bh=p2a1vXXc69O/px1tJS9PHGGSu+bfndAnOjwnw4vFX6M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EfWySZ4M6byH6k6vhTGqzGoLXFN+cKvyOhq2LY7qDhaRi6car3YO8czp2x5eFdKVfPo9EVr+LvvQNozltAhrVkkdM035XDF2iFDoJOflJe09aBMKDYhIgJDVGSYH/PzhAgOGf04jENrP4iKoCINwBq/MP34Ei7dOonL3jZD+vCQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=HX1oGGX/; arc=none smtp.client-ip=209.85.210.193 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HX1oGGX/" Received: by mail-pf1-f193.google.com with SMTP id d2e1a72fcca58-7bf0ad0cb87so6222328b3a.2 for ; Tue, 25 Nov 2025 19:18:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764127100; x=1764731900; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=B7ozaCRL273ETHkhhjpKcicKScA37yYy2L/hbCujZyo=; b=HX1oGGX/ZtNtbAv3xlF6N5t6A1d5G+/Z/KYXUDau0GaMYNz1LQmKXLOIWBUbFo7t0X TFpUaUh1mc0qQdGyQTgvjMaDaXstmcWtImi+OIFehj138Fb5zUg7l1yiF9LMTZxKJqLJ oyRkwznxCWnEsugjDrgN/s+AQYjA7L6c3UP6VewlEMH14mIUJrG8yOmbsCbXWY8qHaof VCkBRhnqRy0vrSnrPZvob4p69OL9ugYSv4OM+0T5aofDl4+zMMAP2eWiR/k9VGK/1xcU cvi8xAm105GyeBioo3imS64lPguRY+pajT4hFEiC+OoTgZkxGn4r+Br1LaUuyMpoU0j/ Jhtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764127100; x=1764731900; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=B7ozaCRL273ETHkhhjpKcicKScA37yYy2L/hbCujZyo=; b=nLxw/6t9feYZ3Lp0fk/bvwiwpVFZkE4VUvFtYIQ31ssMp5j1OMgrHTby9JpqDDosTn /48dMSueOKrlzZWyiVS9ipU/qg+27hOZm0u9GiTDmzWYqCqEk2RdNiq2DRQE/VjbNfi+ xcfEqWRRzKVEWGqz+6rita/FuxwzBJ0hN3ou6F4/Ee2zjBwwYR6rGgD7wz+mU7FkEC8z tcGFtBgGC+Ze72Z8orUo6daq+Y2F3Ny0EgeaZzI292cYgL9U9cvwbw5IXs2UN+Q17WFc o/c+1elSJtSZTNTOSBqgKQ0C0/M6WQe0S9A9f/Wt75NZ+rDctchAeiD5d0J1FXz5mAgd DFYw== X-Forwarded-Encrypted: i=1; AJvYcCX26YjmYfJkC3JtvqTMYkB1wm46qI4CDGSuucyty6wx7xMiRYMN0XQhgztSgUm56aeK6aizv/KI/M60Ktk=@vger.kernel.org X-Gm-Message-State: AOJu0YzPejnaxCH+v8byJzu/fewIHalnk6JY9EojUybSe6edUfQ9mxGn mFlZqfnFedacowkn/HA1zUypYt2NnqBS1+boZ3xKy5tKBdow567tiL+a X-Gm-Gg: ASbGncsCpbfY7SeuRU36Ve+9dZU1sXJSfTLoqHbpwvssbB2xFxH+IA6EQfEu8EY4M8F XYTM6okUojR/HxfhMHvw3bj9GQOJiTM7PuH+lCQoD4cQ0pVSDJy+8oRnAMpFNEAbFMe36rlpLzl 93Bo5NirwuXm/r+PsnPSIPv0wUuoneb2ENMBmln3r8ka4oKO6eSRRECJqT2eYBkhXth6OmAlVLV s1WU6gsOqsR68HyaNRLGMjMYQ8R3xspNXWKSRO3YNXLf/AFkMZ7YqnUA+QGR3wKFGRhdp27+bEY iqBDzqIKFuGv6TUYKca4n+pAzsbWVMoG3VfbcKQIePaMv7LU2+5+CzhkIEv0kPbkpbdIngyfc+j hH0EYz8zYqbxh4K9zAIuU8KtDzp2TxS3cMCe+ZSuvcVaOC1y8r3urDufpIstldDfkqd8UUuucSr tz7Ebk02PVkJ8Mjw== X-Google-Smtp-Source: AGHT+IG4qlNiEEoXWutLGwHJ0G+8UC4lSWmbuW3HpUhf3gSmsfXJsXmVg9/UlI5YsquppzK7NKIpsw== X-Received: by 2002:a05:6a21:3384:b0:35f:aa1b:bc09 with SMTP id adf61e73a8af0-36150e6cff9mr20254369637.17.1764127100409; Tue, 25 Nov 2025 19:18:20 -0800 (PST) Received: from Ubuntu24.. ([103.187.64.30]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-bd760ac62ecsm17935713a12.26.2025.11.25.19.18.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Nov 2025 19:18:20 -0800 (PST) From: Shrikant Raskar To: jic23@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org Cc: dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org, heiko@sntech.de, neil.armstrong@linaro.org, skhan@linuxfoundation.org, david.hunter.linux@gmail.com, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Shrikant Raskar Subject: [PATCH 2/3] iio: proximity: rfd77402: Add Device Tree support Date: Wed, 26 Nov 2025 08:44:39 +0530 Message-ID: <20251126031440.30065-3-raskar.shree97@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251126031440.30065-1-raskar.shree97@gmail.com> References: <20251126031440.30065-1-raskar.shree97@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This patch enables seamless integration of the RFD77402 ToF sensor on platforms that use Device Tree for hardware description Signed-off-by: Shrikant Raskar --- drivers/iio/proximity/rfd77402.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/iio/proximity/rfd77402.c b/drivers/iio/proximity/rfd77= 402.c index aff60a3c1a6f..3262af6f6882 100644 --- a/drivers/iio/proximity/rfd77402.c +++ b/drivers/iio/proximity/rfd77402.c @@ -313,10 +313,17 @@ static const struct i2c_device_id rfd77402_id[] =3D { }; MODULE_DEVICE_TABLE(i2c, rfd77402_id); =20 +static const struct of_device_id rfd77402_of_match[] =3D { + { .compatible =3D "rfdigital,rfd77402" }, + { } +}; +MODULE_DEVICE_TABLE(of, rfd77402_of_match); + static struct i2c_driver rfd77402_driver =3D { .driver =3D { .name =3D RFD77402_DRV_NAME, .pm =3D pm_sleep_ptr(&rfd77402_pm_ops), + .of_match_table =3D rfd77402_of_match, }, .probe =3D rfd77402_probe, .id_table =3D rfd77402_id, --=20 2.43.0 From nobody Mon Dec 1 23:33:39 2025 Received: from mail-pj1-f67.google.com (mail-pj1-f67.google.com [209.85.216.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7F86430DD11 for ; Wed, 26 Nov 2025 03:18:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.67 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764127111; cv=none; b=GyAgCqiCnbzkXPko/kfuR2kKyCptOVtfXrH4pTe/Bd6jY7Dr5pjxmtlTRxMh/bySS+4ZrM5cLXRhPo5CAYayHaZSHumhhmzYgmvY82HMjg5zVpmKuRgxOGRNJm4GG4H2Q5gz7+RgOCXnvKVbRfW7SmjPFofTKuRY7EIHHjq8Zhw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764127111; c=relaxed/simple; bh=O/FdDoWsTtB3kG7n8rW5pom32dgJ0HYrp8tN2uownXQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BFuk2GEE2QJ7/y9supSnJkWsii+Gl2Ws0qJOVxPQu8cnC7HUA8yilaqBEWXohN23mVG/SZ5VhPZ/9Al+aF0CnM8m1gsiFvV6UTH3yi/zsMK7IFt+dxsZSObpFCF1fCuIyMuZ/YFfJ1PGuCl9RQdEp7SNjyfqcyxebGGVNRiViI0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=B15tnNse; arc=none smtp.client-ip=209.85.216.67 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="B15tnNse" Received: by mail-pj1-f67.google.com with SMTP id 98e67ed59e1d1-343dfb673a8so6114607a91.0 for ; Tue, 25 Nov 2025 19:18:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764127109; x=1764731909; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=d6Xe64oeFN/hgEeTq3mr06ewYNBk1gsJ/h1SLYUnJnM=; b=B15tnNse8/SP7HJBWKr55X3EE8Q7di6V7spKV3oBEFS/mSKrX9uDI+45EAYmuHnpy/ MfSTmYRF29aaLsyXkpsCmKhKwF8yjKyMKMosr6aBTpjo8HTdcOiGzv9ICdE8yffMFXp9 BhH2sthYtGkuJbTqO4cJPQsaSFua1SBxJTsg06zXQPCYb+6d3iGC4QWN2DdW7Sh5FLPx igOm0rXhSzrndmvxPxZI+/PMEz6DEpSn2MiZK8LOSSevr/oRmJli8s+ds//I4kMN0Bsz 2H6Vrzs8p3kpqf/Em3cGlIJJCTTIHJbn1MyUEWRBHj10/9RwAbIX7SG+Mf+d0W2IA6h7 /SBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764127109; x=1764731909; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=d6Xe64oeFN/hgEeTq3mr06ewYNBk1gsJ/h1SLYUnJnM=; b=rdZf4Ap+z3OuHhXwFAlfjyVihMRnloZPOOHECb7E6bibXPSN+VxKRWZv/SzIB3aCZz TS4yrL/0lSrJYPe0uqVnwUp6e2ayDP3DJhSI7jF+dMoKeCPYT65tRY7uE2xbYSBmme/m 8AY1gUGvZJW2nS1SvPjcn/HlWyU0IBBklgYak4oF1IOV66w/lcBvTe8m5rMgP6mDnhuT gQtqOG9j/Nq/9unPFJ2JkkAEI0n3PBzPtGgXyjv2w/sCwQeR90Gl9yQ/ixcfQ0GI9sLU dL6WLKpget1dJWQkG1PyyBkaAgzfCP7F9AukQ+tDzfOU/VuWA/p2KZjQmwWvDb8p8/at pqqA== X-Forwarded-Encrypted: i=1; AJvYcCUE8Gikg4S0hK9xFlvCvYdScCDzJc1n38xFbw5CywYD+bBr0aGxlvC6v5ctNwJiP61O6FaHENzsFBpNqyw=@vger.kernel.org X-Gm-Message-State: AOJu0YzHVbIg4bRJNV383eU5p39ycFyBdjLXBgVjiXwuUO66E5LgEG+E 92az5ZSz2r0E5tr/I44l+xL+N8ItTNNyVfRdDXqLdwvxzA9nYqDXN2bV X-Gm-Gg: ASbGnct5KFlRnmxpdyK1vvQ5k2aHTvDAODqm2ht23yvd0FjqBBL1qKue5sJkR4do8vB BU+k/xbl6aiw1/OJHrn6d1KAkR8Bf5/ZlyRtVhSUaqQyFCIJYlrgz6+tgXuELtMa9RQOz5LSSQx ugUD9PKmQt4xnE41J6Crkpd8LQqV/zXhK7n4mQnfYD5Zs8XVE4o8cs5HRGuE3GmaMacwRcCFTlt feokTMHqy6/tcmOfp2RH0cZ5JVPWhHPbjPpOiHtcHSuow5e6lC7GFDzpxObYKo+9M8GUXpTRKrR ceSQA0zaeR6bQK18DuGJIkkg4g0Z8vM0co+NeuXvFLZkZE99sQAtdoiLJawvUNJSdinJdtHL/m5 g+9bAvx1oWWD4Jkb9IvwDPo+UQ3Bz4fANBXGduwcGQ+h0I/XdI5s4uTvCs9d2cFjWSj5aoe430i zhgi19jfv9PDbNnA== X-Google-Smtp-Source: AGHT+IGWuTk86MmM+T3rvGIwhVEhOF0JgQ3Zm8cM9stPPaPkBMDZPrWJaO5FrThxprXCHLKadXm4uA== X-Received: by 2002:a17:90b:4ccd:b0:340:a961:80c5 with SMTP id 98e67ed59e1d1-34733f4d978mr15820722a91.32.1764127108815; Tue, 25 Nov 2025 19:18:28 -0800 (PST) Received: from Ubuntu24.. ([103.187.64.30]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-bd760ac62ecsm17935713a12.26.2025.11.25.19.18.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Nov 2025 19:18:28 -0800 (PST) From: Shrikant Raskar To: jic23@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org Cc: dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org, heiko@sntech.de, neil.armstrong@linaro.org, skhan@linuxfoundation.org, david.hunter.linux@gmail.com, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Shrikant Raskar Subject: [PATCH 3/3] iio: proximity: rfd77402: Add interrupt handling support Date: Wed, 26 Nov 2025 08:44:40 +0530 Message-ID: <20251126031440.30065-4-raskar.shree97@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251126031440.30065-1-raskar.shree97@gmail.com> References: <20251126031440.30065-1-raskar.shree97@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add interrupt handling support to enable event-driven data acquisition instead of continuous polling. This improves responsiveness, reduces CPU overhead, and supports low-power operation by allowing the system to remain idle until an interrupt occurs. Signed-off-by: Shrikant Raskar --- drivers/iio/proximity/rfd77402.c | 127 ++++++++++++++++++++++++++----- 1 file changed, 107 insertions(+), 20 deletions(-) diff --git a/drivers/iio/proximity/rfd77402.c b/drivers/iio/proximity/rfd77= 402.c index 3262af6f6882..0e4763b34267 100644 --- a/drivers/iio/proximity/rfd77402.c +++ b/drivers/iio/proximity/rfd77402.c @@ -6,19 +6,22 @@ * * 7-bit I2C slave address 0x4c * - * TODO: interrupt * https://media.digikey.com/pdf/Data%20Sheets/RF%20Digital%20PDFs/RFD7740= 2.pdf */ =20 #include #include #include - +#include +#include +#include #include =20 #define RFD77402_DRV_NAME "rfd77402" =20 #define RFD77402_ICSR 0x00 /* Interrupt Control Status Register */ +#define RFD77402_ICSR_CLR_CFG BIT(0) +#define RFD77402_ICSR_CLR_TYPE BIT(1) #define RFD77402_ICSR_INT_MODE BIT(2) #define RFD77402_ICSR_INT_POL BIT(3) #define RFD77402_ICSR_RESULT BIT(4) @@ -26,6 +29,12 @@ #define RFD77402_ICSR_H2M_MSG BIT(6) #define RFD77402_ICSR_RESET BIT(7) =20 +#define RFD77402_IER 0x02 +#define RFD77402_IER_RESULT BIT(0) +#define RFD77402_IER_M2H_MSG BIT(1) +#define RFD77402_IER_H2M_MSG BIT(2) +#define RFD77402_IER_RESET BIT(3) + #define RFD77402_CMD_R 0x04 #define RFD77402_CMD_SINGLE 0x01 #define RFD77402_CMD_STANDBY 0x10 @@ -80,6 +89,10 @@ struct rfd77402_data { struct i2c_client *client; /* Serialize reads from the sensor */ struct mutex lock; + /* Completion for interrupt-driven measurements */ + struct completion completion; + /* Flag to indicate if interrupt is available */ + bool irq_en; }; =20 static const struct iio_chan_spec rfd77402_channels[] =3D { @@ -110,8 +123,24 @@ static int rfd77402_set_state(struct i2c_client *clien= t, u8 state, u16 check) return 0; } =20 -static int rfd77402_measure(struct i2c_client *client) +static irqreturn_t rfd77402_interrupt_handler(int irq, void *dev_id) +{ + struct rfd77402_data *data =3D dev_id; + int ret; + + /* Check if the interrupt is from our device */ + ret =3D i2c_smbus_read_byte_data(data->client, RFD77402_ICSR); + if (ret < 0 || !(ret & RFD77402_ICSR_RESULT)) + return IRQ_NONE; + + /* Signal completion of measurement */ + complete(&data->completion); + return IRQ_HANDLED; +} + +static int rfd77402_measure(struct rfd77402_data *data) { + struct i2c_client *client =3D data->client; int ret; int tries =3D 10; =20 @@ -120,24 +149,39 @@ static int rfd77402_measure(struct i2c_client *client) if (ret < 0) return ret; =20 + /* Initialize completion for interrupt mode */ + if (data->irq_en) + reinit_completion(&data->completion); + ret =3D i2c_smbus_write_byte_data(client, RFD77402_CMD_R, RFD77402_CMD_SINGLE | RFD77402_CMD_VALID); if (ret < 0) goto err; =20 - while (tries-- > 0) { - ret =3D i2c_smbus_read_byte_data(client, RFD77402_ICSR); - if (ret < 0) + if (data->irq_en) { + /* Wait for interrupt-driven completion */ + ret =3D wait_for_completion_timeout(&data->completion, + msecs_to_jiffies(200)); + if (ret =3D=3D 0) { + ret =3D -ETIMEDOUT; goto err; - if (ret & RFD77402_ICSR_RESULT) - break; - msleep(20); - } - - if (tries < 0) { - ret =3D -ETIMEDOUT; - goto err; + } + } else { + /* Fallback to polling mode */ + while (tries-- > 0) { + ret =3D i2c_smbus_read_byte_data(client, RFD77402_ICSR); + if (ret < 0) + goto err; + if (ret & RFD77402_ICSR_RESULT) + break; + msleep(20); + } + + if (tries < 0) { + ret =3D -ETIMEDOUT; + goto err; + } } =20 ret =3D i2c_smbus_read_word_data(client, RFD77402_RESULT_R); @@ -168,7 +212,7 @@ static int rfd77402_read_raw(struct iio_dev *indio_dev, switch (mask) { case IIO_CHAN_INFO_RAW: mutex_lock(&data->lock); - ret =3D rfd77402_measure(data->client); + ret =3D rfd77402_measure(data); mutex_unlock(&data->lock); if (ret < 0) return ret; @@ -190,6 +234,8 @@ static const struct iio_info rfd77402_info =3D { =20 static int rfd77402_init(struct i2c_client *client) { + struct iio_dev *indio_dev =3D i2c_get_clientdata(client); + struct rfd77402_data *data =3D iio_priv(indio_dev); int ret, i; =20 ret =3D rfd77402_set_state(client, RFD77402_CMD_STANDBY, @@ -197,11 +243,29 @@ static int rfd77402_init(struct i2c_client *client) if (ret < 0) return ret; =20 - /* configure INT pad as push-pull, active low */ - ret =3D i2c_smbus_write_byte_data(client, RFD77402_ICSR, - RFD77402_ICSR_INT_MODE); - if (ret < 0) - return ret; + if (data->irq_en) { + /* Configure ICSR: auto-clear on read, push-pull, falling edge */ + ret =3D i2c_smbus_write_byte_data(client, RFD77402_ICSR, + RFD77402_ICSR_CLR_CFG | + RFD77402_ICSR_INT_MODE); + if (ret < 0) + return ret; + + /* Enable 'new data available' interrupt in IER */ + ret =3D i2c_smbus_write_byte_data(client, RFD77402_IER, + RFD77402_IER_RESULT); + if (ret < 0) + return ret; + } else { + /* Disable interrupts */ + ret =3D i2c_smbus_write_byte_data(client, RFD77402_ICSR, 0); + if (ret < 0) + return ret; + + ret =3D i2c_smbus_write_byte_data(client, RFD77402_IER, 0); + if (ret < 0) + return ret; + } =20 /* I2C configuration */ ret =3D i2c_smbus_write_word_data(client, RFD77402_I2C_INIT_CFG, @@ -277,6 +341,29 @@ static int rfd77402_probe(struct i2c_client *client) data->client =3D client; mutex_init(&data->lock); =20 + init_completion(&data->completion); + + i2c_set_clientdata(client, indio_dev); + + /* Check if interrupt is mentioned in device tree */ + data->irq_en =3D false; + if (client->irq > 0) { + ret =3D devm_request_threaded_irq(&client->dev, client->irq, + NULL, rfd77402_interrupt_handler, + IRQF_TRIGGER_FALLING | IRQF_ONESHOT, + "rfd77402", data); + if (ret =3D=3D 0) { + data->irq_en =3D true; + dev_info(&client->dev, "Using interrupt mode\n"); + } else { + dev_warn(&client->dev, + "Failed to request IRQ %d, using polling mode: %d\n", + client->irq, ret); + } + } else { + dev_info(&client->dev, "No interrupt specified, using polling mode\n"); + } + indio_dev->info =3D &rfd77402_info; indio_dev->channels =3D rfd77402_channels; indio_dev->num_channels =3D ARRAY_SIZE(rfd77402_channels); --=20 2.43.0