Skip to contentSkip to conversation

iio: magnetometer: add driver for QST QMC5883L Sensor

PATCH In review Siratul Islam 3 participants 6 messages Jun 19 – Jun 23

Subsystems (3)
lore
Share & tools
lore

Siratul Islam

author maintainer
#0 lore raw

v3 cover iio: magnetometer: add driver for QST QMC5883L Sensor

This patch series introduces the QST QMC5883L 3-Axis Magnetic Sensor driver. It is a simple device with minimal magnetometer functionalities. Commonly used as (software incompatible) replacement for the Honeywell HMC5883L sensor.

This driver implements the basic functionalities of the QMC5883L sensor, and intentionally leaves out some features like DRDY interrupt pin support and power management for simplicity, both of which will be addressed in future patches.

There was an attempt to introduce this device about an year ago but the author seems to have abandoned the patch series. Since the device is simple enough, I decided to start from scratch.

Note: I also noticed a patch for the QMC5883P variant. Despite similar naming, the sensors are different including different register maps, so these devices are not compatible with each other.

---
Changes in v3:
- Add trailing commas at list endings
- Rename regmap to map in multiple places
- Add and reorder header includes
- Update POR time comment

Changes in v2:
- Update commit message in binding.
- Reformat header includes.
- Remove iio_device_claim_direct()/iio_device_release_direct()
- Read the measurement registers before checking the OVL status bit
- Replace scoped_guard() with guard()
- Fix function parameter styling
- Replace FIELD_PREP_CONST() with FIELD_PREP()
- Replace qmc5883l_rng_avail[] with a 2D qmc5883l_scales[][2] array
- Update mutex comment
- Add a devm_add_action_or_reset() callback
- Use a named initializer in the i2c_device_id table
- Combine u8 rng, osr, odr; onto one line
- Various styling fixes
- Update maintainer email to [email protected]

Link to v2: https://lore.kernel.org/linux-iio/[email protected]/
Link to v1: https://lore.kernel.org/linux-iio/[email protected]/

Siratul Islam (3):
dt-bindings: add entry for qstcorp
dt-bindings: iio: magnetometer: add QST QMC5883L Sensor
iio: magnetometer: add driver for QST QMC5883L Sensor

 .../iio/magnetometer/qstcorp,qmc5883l.yaml    |  52 ++
 .../devicetree/bindings/vendor-prefixes.yaml  |   2 +
 MAINTAINERS                                   |   7 +
 drivers/iio/magnetometer/Kconfig              |  11 +
 drivers/iio/magnetometer/Makefile             |   2 +
 drivers/iio/magnetometer/qmc5883l.c           | 517 ++++++++++++++++++
 6 files changed, 591 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/magnetometer/qstcorp,qmc5883l.yaml
 create mode 100644 drivers/iio/magnetometer/qmc5883l.c

--
2.54.0

author maintainer
#1 lore raw

PATCH v3 1/3 dt-bindings: add entry for qstcorp

Add an entry for QST Corporation Limited

---
 Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++
 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/vendor-prefixes.yaml +2 -0
index 28784d66ae7b..11aac47f90ce 100644
@@ -1355,6 +1355,8 @@ patternProperties:
     description: Shenzhen QiShenglong Industrialist Co., Ltd.
   "^qnap,.*":
     description: QNAP Systems, Inc.
+  "^qstcorp,.*":
+    description: QST Corporation Limited
   "^quanta,.*":
     description: Quanta Computer Inc.
   "^radxa,.*":
Signature · 1 line
2.54.0
author maintainer
#2 lore raw

PATCH v3 2/3 dt-bindings: iio: magnetometer: add QST QMC5883L Sensor

In reply to Siratul Islam

Add devicetree binding for the QST QMC5883L 3-Axis Magnetic Sensor connected via I2C.
Used enum so that more devices could use this binding

---
 .../iio/magnetometer/qstcorp,qmc5883l.yaml    | 52 +++++++++++++++++++
 MAINTAINERS                                   |  6 +++
 2 files changed, 58 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/magnetometer/qstcorp,qmc5883l.yaml
Documentation/devicetree/bindings/iio/magnetometer/qstcorp,qmc5883l.yaml new file +52 -0
new file mode 100644
index 000000000000..38abd083a4fb
@@ -0,0 +1,52 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/iio/magnetometer/qstcorp,qmc5883l.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: QST QMC5883L 3-Axis Magnetic Sensor
+
+maintainers:
+  - Siratul Islam <[email protected]>
+
+description: |
+  QST QMC5883L 3-Axis Magnetic Sensor on I2C bus.
+  https://www.qstcorp.com/upload/pdf/202512/13-52-04%20QMC5883L%20Datasheet%20Rev.%20B.pdf
+
+properties:
+  compatible:
+    enum:
+      - qstcorp,qmc5883l
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  vdd-supply: true
+
+  vddio-supply: true
+
+additionalProperties: false
+
+required:
+  - compatible
+  - reg
+  - vdd-supply
+  - vddio-supply
+
+examples:
+  - |
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        magnetometer@d {
+            compatible = "qstcorp,qmc5883l";
+            reg = <0x0d>;
+            vdd-supply = <&vdd_3v3_reg>;
+            vddio-supply = <&vdd_3v3_reg>;
+        };
+    };
+...
MAINTAINERS +6 -0
index e035a3be797c..1127403c579b 100644
@@ -21787,6 +21787,12 @@ F:	Documentation/networking/device_drivers/ethernet/freescale/dpaa2/overview.rst
 F:	drivers/bus/fsl-mc/
 F:	include/uapi/linux/fsl_mc.h
 
+QST QMC5883L 3-Axis Magnetic Sensor
+M:	Siratul Islam <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	Documentation/devicetree/bindings/iio/magnetometer/qstcorp,qmc5883l.yaml
+
 QT1010 MEDIA DRIVER
 L:	[email protected]
 S:	Orphan
Signature · 1 line
2.54.0
author maintainer
#3 lore raw

PATCH v3 3/3 iio: magnetometer: add driver for QST QMC5883L Sensor

In reply to Siratul Islam

Add driver for the QST QMC5883L 3-Axis Magnetic Sensor connected via i2c.

---
 MAINTAINERS                         |   1 +
 drivers/iio/magnetometer/Kconfig    |  11 +
 drivers/iio/magnetometer/Makefile   |   2 +
 drivers/iio/magnetometer/qmc5883l.c | 517 ++++++++++++++++++++++++++++
 4 files changed, 531 insertions(+)
 create mode 100644 drivers/iio/magnetometer/qmc5883l.c
MAINTAINERS +1 -0
index 1127403c579b..0f9ad3b49a5d 100644
@@ -21792,6 +21792,7 @@ M:	Siratul Islam <[email protected]>
 L:	[email protected]
 S:	Maintained
 F:	Documentation/devicetree/bindings/iio/magnetometer/qstcorp,qmc5883l.yaml
+F:	drivers/iio/magnetometer/qmc5883l.c
 
 QT1010 MEDIA DRIVER
 L:	[email protected]
drivers/iio/magnetometer/Kconfig +11 -0
index fb313e591e85..615564174086 100644
@@ -198,6 +198,17 @@ config INFINEON_TLV493D
 	  To compile this driver as a module, choose M here: the module
 	  will be called tlv493d.
 
+config QMC5883L
+	tristate "QST QMC5883L 3-Axis Magnetic Sensor"
+	depends on I2C
+	select REGMAP_I2C
+	help
+	  Say Y here to add support driver for QST QMC5883L 3-Axis
+	  Magnetic Sensor.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called qmc5883l.
+
 config SENSORS_HMC5843
 	tristate
 	select IIO_BUFFER
drivers/iio/magnetometer/Makefile +2 -0
index 5bd227f8c120..552682555d86 100644
@@ -26,6 +26,8 @@ obj-$(CONFIG_IIO_ST_MAGN_SPI_3AXIS) += st_magn_spi.o
 
 obj-$(CONFIG_INFINEON_TLV493D)		+= tlv493d.o
 
+obj-$(CONFIG_QMC5883L)			+= qmc5883l.o
+
 obj-$(CONFIG_SENSORS_HMC5843)		+= hmc5843_core.o
 obj-$(CONFIG_SENSORS_HMC5843_I2C)	+= hmc5843_i2c.o
 obj-$(CONFIG_SENSORS_HMC5843_SPI)	+= hmc5843_spi.o
drivers/iio/magnetometer/qmc5883l.c new file +517 -0

517 lines not on this page · raw message

Signature · 1 line
2.54.0
maintainer
#4 lore raw
Quoted 4 lines · On Fri, 19 Jun 2026 16:45:06 +0600 Siratul Islam <[email protected]>…

Add driver for the QST QMC5883L 3-Axis Magnetic Sensor connected via i2c.

I'm going to apply this now but given rc1 is still some way off plenty of time for more feedback or tags!

Applied to the testing branch of iio.git with a tiny tweak.

Thanks,

Jonathan

Quoted 6 lines
drivers/iio/magnetometer/qmc5883l.c new file +0 -0
new file mode 100644
index 000000000000..b7fff3b63ca4

drivers/iio/magnetometer/qmc5883l.c line 9

Quoted 9 lines
drivers/iio/magnetometer/qmc5883l.c new file +9 -0
@@ -0,0 +1,517 @@
+// SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause
+/*
+ * Support for QST QMC5883L 3-Axis Magnetic Sensor on I2C bus.
+ *
+ * Copyright (C) 2026 Siratul Islam <[email protected]>
+ *
+ * Datasheet available at
+ * <https://www.qstcorp.com/upload/pdf/202512/13-52-04%20QMC5883L%20Datasheet%20Rev.%20B.pdf>
+ *

My pet trivial complaint. Blank line adds nothing useful. I'll remove it whilst applying ;)

Quoted 1 line
drivers/iio/magnetometer/qmc5883l.c new file +1 -0
+ */