[RFC PATCH 3/3] iio: proximity: srf04: Add Cytron HC-SR04 support
From: Paweł Wiśniewski
Date: Thu Jul 16 2026 - 13:37:16 EST
Tested on a Raspberry Pi 3 Model B+ running
6.18.34+rpt-rpi-v8. The sensor was instantiated using only the
cytron,hc-sr04 compatible, with trigger connected to GPIO17 and echo
connected to GPIO27 through a 5 V to 3.3 V resistor divider. The
driver bound to the device, registered an IIO device, and returned
changing distance readings through in_distance_raw.
Assisted-by: ChatGPT:GPT-5.6 Thinking
Signed-off-by: Paweł Wiśniewski <pawel.wis.me@xxxxxxxxx>
---
drivers/iio/proximity/Kconfig | 1 +
drivers/iio/proximity/srf04.c | 1 +
2 files changed, 2 insertions(+)
diff --git a/drivers/iio/proximity/Kconfig b/drivers/iio/proximity/Kconfig
index bb77fad2a1b3..89e9d57ceba6 100644
--- a/drivers/iio/proximity/Kconfig
+++ b/drivers/iio/proximity/Kconfig
@@ -139,6 +139,7 @@ config SRF04
ranger sensor. This driver can be used to measure the distance
of objects. It is using two GPIOs.
Actually Supported types are:
+ - Cytron HC-SR04
- Devantech SRF04
- Maxbotix mb1000
- Maxbotix mb1010
diff --git a/drivers/iio/proximity/srf04.c b/drivers/iio/proximity/srf04.c
index 7be50bdebfcb..f5ee7d6572b5 100644
--- a/drivers/iio/proximity/srf04.c
+++ b/drivers/iio/proximity/srf04.c
@@ -231,6 +231,7 @@ static const struct iio_chan_spec srf04_chan_spec[] = {
};
static const struct of_device_id of_srf04_match[] = {
+ { .compatible = "cytron,hc-sr04", .data = &srf04_cfg },
{ .compatible = "devantech,srf04", .data = &srf04_cfg },
{ .compatible = "maxbotix,mb1000", .data = &mb_lv_cfg },
{ .compatible = "maxbotix,mb1010", .data = &mb_lv_cfg },
--
2.47.3