Skip to content

Conversation

MarileneGarcia
Copy link

@MarileneGarcia MarileneGarcia commented Jul 13, 2025

The MAX14001/MAX14002 are configurable, isolated 10-bit ADCs for multi-range binary inputs.

Datasheet:
Link: https://www.analog.com/media/en/technical-documentation/data-sheets/MAX14001-MAX14002.pdf

PR Description

Basic IIO ADC max14001 driver features:

  • Definitions for register addresses and useful constants (if any).
  • Definitions for the IIO channels.
  • Device state struct.
  • read_raw and write_raw function implementations (just a mock for now).
  • iio_info struct populated with a reference to the read_raw and write_raw functions.
  • Probe function to initialize and make basic setup for the device.
  • SPI and device tree MODULE_DEVICE_TABLEs
  • Device tree overlay for Raspberry Pi 5
  • Basic max14001 SPI read and write functions

PR Type

  • New feature (a change that adds new functionality)

PR Checklist

  • I have conducted a self-review of my own code changes
  • I tested it on the Raspberry Pi, but without the max14001 board, I couldn't fully validate it yet.
  • Evidence of some basic features working
Screenshot from 2025-07-13 20-02-34

Copy link
Contributor

@machschmitt machschmitt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @MarileneGarcia , a few comments about this initial driver version.
Note that, aside from the comments above, there are still some improvements that need to be made to make this driver usable (e.g. read ADC sample data, provide scale to convert output codes to mV). Those features shall be implemented next. Though, overall, this looks good to me as an initial driver version.

Copy link

@jonathanns jonathanns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few more notes.

@MarileneGarcia
Copy link
Author

Hi @MarileneGarcia , a few comments about this initial driver version. Note that, aside from the comments above, there are still some improvements that need to be made to make this driver usable (e.g. read ADC sample data, provide scale to convert output codes to mV). Those features shall be implemented next. Though, overall, this looks good to me as an initial driver version.

Ok, thank you for the comments! I think I have address them. I will start working in the other needed features, like the read ADC sample data and provide scale to convert output codes to mV.

@MarileneGarcia MarileneGarcia force-pushed the rpi-6.6.y_GSOC_2025_MAX14001 branch from d29debd to f6eaef5 Compare July 20, 2025 15:37
@MarileneGarcia
Copy link
Author

Just a few more notes.

Ok, thank you for the comments! I think I have address them. The ones related to the write_raw I am going to check in the next steps.

@MarileneGarcia MarileneGarcia force-pushed the rpi-6.6.y_GSOC_2025_MAX14001 branch from f6eaef5 to b451319 Compare July 20, 2025 15:50
Copy link
Contributor

@machschmitt machschmitt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

A few more comments.
The regulator thing can be done on a different PR (we might need to rebase or create another GSoC branch if updating to kernel 6.12).

Keep up the good work.

@MarileneGarcia MarileneGarcia force-pushed the rpi-6.6.y_GSOC_2025_MAX14001 branch from d83610c to 42f812b Compare July 24, 2025 11:01
Copy link
Contributor

@machschmitt machschmitt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @MarileneGarcia , the updates to MAX14001 driver look mostly good to me. I would merge the PR, but I think it will actually be easier to do the suggested changes before merging this rather than doing them later. So, I'll wait until the last adjustments are done to merge this PR.

@MarileneGarcia
Copy link
Author

Hi @MarileneGarcia , the updates to MAX14001 driver look mostly good to me. I would merge the PR, but I think it will actually be easier to do the suggested changes before merging this rather than doing them later. So, I'll wait until the last adjustments are done to merge this PR.

Hello @machschmitt. Sure, I have done the requested changes, thank you!
I also submitted the initial version of the device tree documentation. And a new method to set the value of the verification registers, which should be done every time the device powers up.

@MarileneGarcia MarileneGarcia force-pushed the rpi-6.6.y_GSOC_2025_MAX14001 branch from 81f5aa9 to 6c5e260 Compare July 27, 2025 23:39
@MarileneGarcia MarileneGarcia force-pushed the rpi-6.6.y_GSOC_2025_MAX14001 branch from 3bd2356 to 295b094 Compare August 7, 2025 01:06
Copy link
Contributor

@machschmitt machschmitt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @MarileneGarcia , a few comments about the dt-bindings and new code. I'll have a closer look at MAX14001 data sheets to provide a more accurate review this weekend.

@MarileneGarcia MarileneGarcia force-pushed the rpi-6.6.y_GSOC_2025_MAX14001 branch 2 times, most recently from c6e0590 to 34cee15 Compare August 14, 2025 11:04
Copy link
Contributor

@machschmitt machschmitt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @MarileneGarcia,

This initial driver version looks very good.
I'm leaving a few suggestions.
Aside from a few potentially buggy things, most of the comments are about code style nitpicking.

My advise is to address those last nits and send it to the mailing lists. Experienced kernel maintainers may find further possible improvements for this driver but I do think this is a very good starting point for upstream review.

{
.tx_buf = &st->tx_buffer,
.len = sizeof(st->tx_buffer),
.bits_per_word = 16,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, did you really need that? I think it's unlikely that rpi5 SPI controller actually supports 16 bits_per_word since rpi4 SPI controller only supported 8 bits_per_word. I would just drop bits_per_word = 16, unless somehow rpi5 supports it and register read stops working without that.

@MarileneGarcia MarileneGarcia force-pushed the rpi-6.6.y_GSOC_2025_MAX14001 branch 3 times, most recently from 7e74a0e to 248596e Compare August 17, 2025 13:51
@MarileneGarcia
Copy link
Author

Hi @MarileneGarcia,

This initial driver version looks very good. I'm leaving a few suggestions. Aside from a few potentially buggy things, most of the comments are about code style nitpicking.

My advise is to address those last nits and send it to the mailing lists. Experienced kernel maintainers may find further possible improvements for this driver but I do think this is a very good starting point for upstream review.

Okay, I believe I’ve addressed them, but I’ll wait for your approval before sending the patches to the maintainers.
Thank you.

@machschmitt
Copy link
Contributor

Okay, I believe I’ve addressed them, but I’ll wait for your approval before sending the patches to the maintainers.

The patches look great. But, unfortunately, they don't apply to IIO testing branch. The patches need to be ported to the testing branch of IIO tree. It should not be hard to port the patches by editing the git hunks.
Change patch1 hunk to be like

@@ -14952,6 +14952,13 @@ F:	drivers/iio/amplifiers/hmc425a.c
 F:	Documentation/devicetree/bindings/iio/adc/maxim,max11205.yaml
 F:	drivers/iio/adc/max11205.c
 
+ANALOG DEVICES INC MAX14001 DRIVER
+M:	Marilene Andrade Garcia <[email protected]>
+L:	[email protected]
+S:	Maintained
+W:	https://ez.analog.com/linux-software-drivers
+F:	Documentation/devicetree/bindings/iio/adc/adi,max14001.yaml
+
 MAXIM MAX17040 FAMILY FUEL GAUGE DRIVERS
 R:	Iskren Chernev <[email protected]>
 R:	Krzysztof Kozlowski <[email protected]>

change patch2 to be like

@@ -14958,6 +14958,7 @@ L:	[email protected]
 S:	Maintained
 W:	https://ez.analog.com/linux-software-drivers
 F:	Documentation/devicetree/bindings/iio/adc/adi,max14001.yaml
+F:	drivers/iio/adc/max14001.c
 
 MAXIM MAX17040 FAMILY FUEL GAUGE DRIVERS
 R:	Iskren Chernev <[email protected]>
diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
index d3d12ed064e5..22b348bb675a 100644
--- a/drivers/iio/adc/Kconfig
+++ b/drivers/iio/adc/Kconfig
@@ -979,6 +979,16 @@ config MAX11205
 	  To compile this driver as a module, choose M here: the module will be
 	  called max1363.
 
+config MAX14001
+	tristate "Analog Devices MAX14001/MAX14002 ADCs driver"
+	depends on SPI
+	help
+	  Say yes here to build support for Analog Devices MAX14001/MAX14002
+	  Configurable, Isolated 10-bit ADCs for Multi-Range Binary Inputs.
+
+	  To compile this driver as a module, choose M here: the module will be
+	  called max14001.
+
 config MAX34408
 	tristate "Maxim max34408/max344089 ADC driver"
 	depends on I2C
diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile
index 6a71631c9842..bc4c6d7a57dd 100644
--- a/drivers/iio/adc/Makefile
+++ b/drivers/iio/adc/Makefile
@@ -86,6 +86,7 @@ obj-$(CONFIG_MAX11205) += max11205.o
 obj-$(CONFIG_MAX11410) += max11410.o
 obj-$(CONFIG_MAX1241) += max1241.o
 obj-$(CONFIG_MAX1363) += max1363.o
+obj-$(CONFIG_MAX14001) += max14001.o
 obj-$(CONFIG_MAX34408) += max34408.o
 obj-$(CONFIG_MAX77541_ADC) += max77541-adc.o
 obj-$(CONFIG_MAX9611) += max9611.o

We may talk more about it at next week's meeting.

@MarileneGarcia MarileneGarcia force-pushed the rpi-6.6.y_GSOC_2025_MAX14001 branch from 248596e to a4cd2bb Compare August 18, 2025 11:22
Add device-tree documentation for MAX14001/MAX14002 ADCs.
The MAX14001/MAX14002 are isolated, single-channel analog-to-digital
converters with programmable voltage comparators and inrush current
control optimized for configurable binary input applications.

Signed-off-by: Marilene Andrade Garcia <[email protected]>
The MAX14001/MAX14002 are configurable, isolated 10-bit ADCs for
multi-range binary inputs. Besides the ADC readings, the MAX14001/MAX14002
offers more features, like a binary comparator, a filtered reading that
can provide the average of the last 2, 4, or 8 ADC readings, and an inrush
comparator that triggers the inrush current. There is also a fault feature
that can diagnose seven possible fault conditions. And an option to select
an external or internal ADC voltage reference.

Add basic support for MAX14001/MAX14002 with the following features:
- Raw ADC reading.
- Filtered ADC average reading with the default configuration.

Signed-off-by: Marilene Andrade Garcia <[email protected]>
The MAX14001 is a configurable, isolated 10-bit ADC for multi-range binary
inputs. Besides the ADC readings, the MAX14001 offers more features, like
a binary comparator, a filtered reading that can provide the average of
the last 2, 4, or 8 ADC readings, and an inrush comparator that triggers
the inrush current. There is also a fault feature that can diagnose seven
possible fault conditions. And an option to select an external or internal
ADC voltage reference.

The MAX14001PMB provides the hardware to evaluate the MAX14001 to measure
two channels of data, line voltage and load current.

Signed-off-by: Marilene Andrade Garcia <[email protected]>
@MarileneGarcia MarileneGarcia force-pushed the rpi-6.6.y_GSOC_2025_MAX14001 branch from a4cd2bb to d6dc4f7 Compare August 19, 2025 01:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants