[PATCH v2 0/2] iio: magnetometer: add MEMSIC MMC5983MA driver

Vladislav Kulikov posted 2 patches 1 month ago
There is a newer version of this series
.../iio/magnetometer/memsic,mmc5983.yaml      |  65 ++++
MAINTAINERS                                   |   7 +
drivers/iio/magnetometer/Kconfig              |  11 +
drivers/iio/magnetometer/Makefile             |   1 +
drivers/iio/magnetometer/mmc5983.c            | 351 ++++++++++++++++++
5 files changed, 435 insertions(+)
create mode 100644 Documentation/devicetree/bindings/iio/magnetometer/memsic,mmc5983.yaml
create mode 100644 drivers/iio/magnetometer/mmc5983.c
[PATCH v2 0/2] iio: magnetometer: add MEMSIC MMC5983MA driver
Posted by Vladislav Kulikov 1 month ago
Add an IIO driver for the MEMSIC MMC5983MA 3-axis magnetometer over
I2C. The driver provides raw magnetic field readings with
per-measurement SET/RESET offset cancellation, giving 18-bit output
with a full-scale range of +/-8 Gauss.

Tested on a Raspberry Pi 2B with the sensor on I2C-1 at 0x30.

The initial driver implements the validated I2C single-measurement path.
Other chip features are left for future work:

- SPI transport: the binding describes SPI wiring, but driver support is
  left for follow-up validation of the SPI command and SET/RESET
  sequencing.
- Temperature channel: left until the temperature output behavior is
  better validated.
- Continuous measurement mode and Auto SET/RESET: left until the
  interaction between CMM, TM_M, Meas_M_Done, and SET/RESET sequencing
  is better understood.
- Saturation/self-test bits and BW/decimation tuning: not exposed until
  their behavior can be described reliably through stable IIO ABI.

The driver uses a conservative 500 us post-SET/RESET delay before
starting the following measurement. The datasheet describes a 500 ns
SET/RESET coil pulse, but testing showed that a longer software delay is
needed before taking the next measurement.

Changes since v1:
- DT binding:
  - added SPI bus support, interrupts, and vddio-supply
  - made vdd-supply required
  - switched to unevaluatedProperties with spi-peripheral-props ref
- Driver:
  - replaced scoped_guard() with guard(mutex) in a case block
  - added datasheet page references for timing values
  - changed product ID mismatch from probe failure to dev_info()
  - hardcoded the IIO device name
  - added trailing commas
  - added local struct device and regmap pointers in mmc5983_init()
- MAINTAINERS:
  - split binding and driver F: entries across the relevant patches

Thank you Jonathan for the review and quick response.

Vladislav Kulikov (2):
  dt-bindings: iio: magnetometer: add MEMSIC MMC5983MA
  iio: magnetometer: add driver for MEMSIC MMC5983MA

 .../iio/magnetometer/memsic,mmc5983.yaml      |  65 ++++
 MAINTAINERS                                   |   7 +
 drivers/iio/magnetometer/Kconfig              |  11 +
 drivers/iio/magnetometer/Makefile             |   1 +
 drivers/iio/magnetometer/mmc5983.c            | 351 ++++++++++++++++++
 5 files changed, 435 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/magnetometer/memsic,mmc5983.yaml
 create mode 100644 drivers/iio/magnetometer/mmc5983.c


base-commit: 7fd2df204f342fc17d1a0bfcd474b24232fb0f32
-- 
2.43.0
Re: [PATCH v2 0/2] iio: magnetometer: add MEMSIC MMC5983MA driver
Posted by David Lechner 1 month ago
On 5/7/26 3:50 PM, Vladislav Kulikov wrote:
> Add an IIO driver for the MEMSIC MMC5983MA 3-axis magnetometer over
> I2C. The driver provides raw magnetic field readings with
> per-measurement SET/RESET offset cancellation, giving 18-bit output
> with a full-scale range of +/-8 Gauss.
> 
I wish all new drivers looked this good. :-)

Reviewed-by: David Lechner <dlechner@baylibre.com>
Re: [PATCH v2 0/2] iio: magnetometer: add MEMSIC MMC5983MA driver
Posted by Andy Shevchenko 1 month ago
On Thu, May 07, 2026 at 08:50:30PM +0000, Vladislav Kulikov wrote:
> Add an IIO driver for the MEMSIC MMC5983MA 3-axis magnetometer over
> I2C. The driver provides raw magnetic field readings with
> per-measurement SET/RESET offset cancellation, giving 18-bit output
> with a full-scale range of +/-8 Gauss.
> 
> Tested on a Raspberry Pi 2B with the sensor on I2C-1 at 0x30.
> 
> The initial driver implements the validated I2C single-measurement path.
> Other chip features are left for future work:
> 
> - SPI transport: the binding describes SPI wiring, but driver support is
>   left for follow-up validation of the SPI command and SET/RESET
>   sequencing.
> - Temperature channel: left until the temperature output behavior is
>   better validated.
> - Continuous measurement mode and Auto SET/RESET: left until the
>   interaction between CMM, TM_M, Meas_M_Done, and SET/RESET sequencing
>   is better understood.
> - Saturation/self-test bits and BW/decimation tuning: not exposed until
>   their behavior can be described reliably through stable IIO ABI.
> 
> The driver uses a conservative 500 us post-SET/RESET delay before
> starting the following measurement. The datasheet describes a 500 ns
> SET/RESET coil pulse, but testing showed that a longer software delay is
> needed before taking the next measurement.

My comment from v1 still applies. Note, when sending a new version of a driver
like this, give approximately as many days as hundreds of LoC in it.
The bare minimum 24h anyway.

-- 
With Best Regards,
Andy Shevchenko
Re: [PATCH v2 0/2] iio: magnetometer: add MEMSIC MMC5983MA driver
Posted by Vlad 1 month ago
On Fri, May 8, 2026 at 1:03 PM Andy Shevchenko
<andriy.shevchenko@intel.com> wrote:
> My comment from v1 still applies. Note, when sending a new version of a driver
> like this, give approximately as many days as hundreds of LoC in it.
> The bare minimum 24h anyway.

Thanks, understood about the revision cadence. I will wait longer before
sending the next version.

I did include a short explanation in patch 1/2, but I see that it should
also be visible in the cover letter for a new driver series. Unless you
think the existing note in patch 1/2 is sufficient, I will add a
dedicated "why a new driver" section to the cover letter in v3.

Best regards,
Vladi
Re: [PATCH v2 0/2] iio: magnetometer: add MEMSIC MMC5983MA driver
Posted by Andy Shevchenko 1 month ago
On Fri, May 08, 2026 at 01:40:17PM +0300, Vlad wrote:
> On Fri, May 8, 2026 at 1:03 PM Andy Shevchenko
> <andriy.shevchenko@intel.com> wrote:
> > My comment from v1 still applies. Note, when sending a new version of a driver
> > like this, give approximately as many days as hundreds of LoC in it.
> > The bare minimum 24h anyway.
> 
> Thanks, understood about the revision cadence. I will wait longer before
> sending the next version.
> 
> I did include a short explanation in patch 1/2, but I see that it should
> also be visible in the cover letter for a new driver series. Unless you
> think the existing note in patch 1/2 is sufficient, I will add a
> dedicated "why a new driver" section to the cover letter in v3.

I'm waiting for this before reviewing. I.o.w. it's crucial to me to even
start the review round. It's up to you what to do on this.

-- 
With Best Regards,
Andy Shevchenko