public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC] iio: magnetometer: mlx90393 - regmap vs command-based access
@ 2026-04-23 12:18 Nikhil Gautam
  2026-04-23 12:25 ` Nikhil Gautam
  0 siblings, 1 reply; 5+ messages in thread
From: Nikhil Gautam @ 2026-04-23 12:18 UTC (permalink / raw)
  To: linux-iio; +Cc: jic23, dlechner, nuno.sa, andy, linux-kernel, Nikhil Gautam

Hi,

I am working on adding support for the MLX90393 magnetometer.

The device uses a command-based protocol (e.g. SM, RM, RR)
rather than a traditional register map.

Before proceeding, I wanted to clarify the preferred design:

- Should regmap be used in such cases, even without a linear
  register map?

- Or is it acceptable to implement a custom command-based
  abstraction layer?

My understanding is that regmap may not be a good fit here,
but I would appreciate guidance before implementing.

Also, pointers to similar IIO drivers would be helpful.

Thanks,
Nikhil Gautam

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC] iio: magnetometer: mlx90393 - regmap vs command-based access
  2026-04-23 12:18 [RFC] iio: magnetometer: mlx90393 - regmap vs command-based access Nikhil Gautam
@ 2026-04-23 12:25 ` Nikhil Gautam
  2026-04-23 17:43   ` Andy Shevchenko
  0 siblings, 1 reply; 5+ messages in thread
From: Nikhil Gautam @ 2026-04-23 12:25 UTC (permalink / raw)
  To: linux-iio; +Cc: jic23, dlechner, nuno.sa, andy, linux-kernel, Nikhil Gautam

Hi,

Apologies for missing a few details in the previous mail.

The MLX90393 supports both I2C and SPI interfaces.

Commands include, for example:
- SM (Start Measurement)
- RM (Read Measurement)
- RR (Read Register)

Given this command-oriented interface over both I2C and SPI,
I wanted to confirm whether a custom command abstraction layer
would still be the preferred approach instead of regmap.

Thanks,
Nikhil Gautam

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC] iio: magnetometer: mlx90393 - regmap vs command-based access
  2026-04-23 12:25 ` Nikhil Gautam
@ 2026-04-23 17:43   ` Andy Shevchenko
  2026-04-24 10:48     ` Jonathan Cameron
  0 siblings, 1 reply; 5+ messages in thread
From: Andy Shevchenko @ 2026-04-23 17:43 UTC (permalink / raw)
  To: Nikhil Gautam; +Cc: linux-iio, jic23, dlechner, nuno.sa, andy, linux-kernel

On Thu, Apr 23, 2026 at 05:55:35PM +0530, Nikhil Gautam wrote:
> 
> Apologies for missing a few details in the previous mail.
> 
> The MLX90393 supports both I2C and SPI interfaces.
> 
> Commands include, for example:
> - SM (Start Measurement)
> - RM (Read Measurement)
> - RR (Read Register)
> 
> Given this command-oriented interface over both I2C and SPI,
> I wanted to confirm whether a custom command abstraction layer
> would still be the preferred approach instead of regmap.

I found only 4 drivers for this vendor in the kernel and they seem
either register based or eeprom based. Perhaps the latter is the
case here? Have you checked existing implementations?

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC] iio: magnetometer: mlx90393 - regmap vs command-based access
  2026-04-23 17:43   ` Andy Shevchenko
@ 2026-04-24 10:48     ` Jonathan Cameron
  2026-04-24 12:57       ` Nikhil Gautam
  0 siblings, 1 reply; 5+ messages in thread
From: Jonathan Cameron @ 2026-04-24 10:48 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Nikhil Gautam, linux-iio, dlechner, nuno.sa, andy, linux-kernel

On Thu, 23 Apr 2026 20:43:55 +0300
Andy Shevchenko <andriy.shevchenko@intel.com> wrote:

> On Thu, Apr 23, 2026 at 05:55:35PM +0530, Nikhil Gautam wrote:
> > 
> > Apologies for missing a few details in the previous mail.
> > 
> > The MLX90393 supports both I2C and SPI interfaces.
> > 
> > Commands include, for example:
> > - SM (Start Measurement)
> > - RM (Read Measurement)
> > - RR (Read Register)
> > 
> > Given this command-oriented interface over both I2C and SPI,
> > I wanted to confirm whether a custom command abstraction layer
> > would still be the preferred approach instead of regmap.  
> 
> I found only 4 drivers for this vendor in the kernel and they seem
> either register based or eeprom based. Perhaps the latter is the
> case here? Have you checked existing implementations?
> 

If it doesn't match up with an existing case.

I took a look at the datasheet and this is a weird mix
of a register driven and command driven device.  As such you could
do regmap for the registers, buy you'd need to bypass that for
the command only stuff.  I don't think it's worth the mess of
creating some virtual registers to deal with the commands.

Hence I think in this particular case regmap doesn't look suitable
and a custom bus abstraction layer makes sense.  Some of that is going
to look regmap like, but with some other callbacks as well.

Jonathan

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC] iio: magnetometer: mlx90393 - regmap vs command-based access
  2026-04-24 10:48     ` Jonathan Cameron
@ 2026-04-24 12:57       ` Nikhil Gautam
  0 siblings, 0 replies; 5+ messages in thread
From: Nikhil Gautam @ 2026-04-24 12:57 UTC (permalink / raw)
  To: jic23, linux-iio
  Cc: andriy.shevchenko, linux-kernel, Nikhil Gautam, dlechner, nuno.sa,
	andy

Hi Andy, Jonathan,

Thanks for taking a look and for the guidance.

The MLX90393 does indeed expose a mix of command-based operations
(SM, RM, etc.) along with limited register access (RR/WR), so it
does not map cleanly to a purely register-based model.

Based on your feedback, I will proceed with a custom command
abstraction layer instead of using regmap. The idea is to keep a
clean separation between command handling, register access, and
bus transport (I2C/SPI), while keeping the structure somewhat
regmap-like where it makes sense.

I will put together an RFC patch with the initial implementation
(I2C support first) and share it shortly for review.

Thanks again for the feedback.

Best regards,
Nikhil Gautam

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-04-24 12:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-23 12:18 [RFC] iio: magnetometer: mlx90393 - regmap vs command-based access Nikhil Gautam
2026-04-23 12:25 ` Nikhil Gautam
2026-04-23 17:43   ` Andy Shevchenko
2026-04-24 10:48     ` Jonathan Cameron
2026-04-24 12:57       ` Nikhil Gautam

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox