Skip to content

Conversation

@bogdanovs
Copy link
Contributor

Add max22190 gpio driver with input functionality, since device support only input with output.

Implemented diagnostic funcionality for all 8 channels which include various check to over/under voltage and wire break. Filtering configuration is done from devicetree on per channel bases and is configured on chip start.

In case of some fault condition occure FAULT pin drive LOW which prop to FAULT registers to be read. Data is stored in data structure for furter analizes and ERR message is prited in console.

@zephyrbot zephyrbot added area: Devicetree Binding PR modifies or adds a Device Tree binding area: GPIO platform: ADI Analog Devices, Inc. labels Apr 5, 2024
@bogdanovs bogdanovs force-pushed the adi-max22190-gpio branch 2 times, most recently from 5ac5f2c to 823f4da Compare April 8, 2024 11:07
@zephyrbot zephyrbot requested a review from decsny April 22, 2024 10:09
@bogdanovs bogdanovs force-pushed the adi-max22190-gpio branch 2 times, most recently from d903a24 to 1aa75d3 Compare April 22, 2024 11:58
decsny
decsny previously requested changes Apr 22, 2024
Copy link
Member

Choose a reason for hiding this comment

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

default value requires justification in description (same for other properties)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure, I add clarification for all. Could you take a look if it is enough ?

Copy link
Member

Choose a reason for hiding this comment

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

I think for the mode you should just remove the default value, it needs to be specified in the board DT, it is hardwired signals on the board after all, needs to be described

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I specified default value because this was mode set on the devkit it self, but it make sens to have it in DT.

@bogdanovs bogdanovs requested a review from decsny April 23, 2024 11:34
Copy link
Member

Choose a reason for hiding this comment

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

I think for the mode you should just remove the default value, it needs to be specified in the board DT, it is hardwired signals on the board after all, needs to be described

Copy link
Member

Choose a reason for hiding this comment

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

I think you should clarify that this default value is not the default value of the hardware

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it is better all filter-wbes , filter-fbps and filter-delays to have for default values from datasheet.
This mean:

  • wire break - 0 disable
  • fbps - 1 bypass
  • delays - 50

Value which was set is the one which is in use in case WBE is 1. In that case delays is 20000.

Copy link
Member

Choose a reason for hiding this comment

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

okay, but now the description seems wrong, it still says set 1? is it intentional, it seems unclear at best

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe my language here is not quiet clear. I want to state that by default every channel is with disabled Wire Break functionality - WBEx bit = 0.
To enable specific channel Wire Break functionality WBEx bit = 1.
Example for channel first 4 channels enabled WB and last 4 disabled WB
[ 1, 1, 1, 1, 0, 0, 0, 0]

If you have some suggestions how to make it clearer please share it.

Copy link
Member

Choose a reason for hiding this comment

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

word this more like "The default value corresponds to the default value of the hardware"

Copy link
Member

Choose a reason for hiding this comment

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

similar comment as above

@bogdanovs bogdanovs requested a review from decsny April 23, 2024 19:00
@decsny decsny dismissed their stale review April 23, 2024 19:45

addressed

Copy link
Member

@MaureenHelm MaureenHelm left a comment

Choose a reason for hiding this comment

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

Please add to drivers/build_all/gpio/app.overlay

@bogdanovs bogdanovs requested a review from MaureenHelm April 25, 2024 12:27
@bogdanovs bogdanovs force-pushed the adi-max22190-gpio branch 3 times, most recently from 21d8d38 to 36b0edc Compare May 13, 2024 12:22
@bogdanovs bogdanovs force-pushed the adi-max22190-gpio branch 2 times, most recently from f52e6fc to 06ff40a Compare October 21, 2024 08:23
@bogdanovs bogdanovs requested a review from MaureenHelm October 21, 2024 12:20
@Piziwate
Copy link
Contributor

Piziwate commented Oct 21, 2024

Thank you for this contribution, which I find interesting. However, I have a few small remarks or suggestions :

  • It seems to me that the latch pin is configured but never used. Typically, it is used when the IC operates in Daisy Chain mode.
  • It would be very beneficial to support Daisy Chain mode, as it is frequently used with this type of IC.

Another more general remark regarding the GPIO API: it is unfortunate that it is not possible to report errors on the GPIOs through the API (such as wire break, fault, etc.). The reading and analysis of error registers only provide output to the console. This is not very useful for normal operating conditions.

MaureenHelm
MaureenHelm previously approved these changes Oct 21, 2024
@bogdanovs
Copy link
Contributor Author

Thanks @Piziwate

  • It seems to me that the latch pin is configured but never used. Typically, it is used when the IC operates in Daisy Chain mode.
  • It would be very beneficial to support Daisy Chain mode, as it is frequently used with this type of IC.

Agree it will be useful, I can add support for that in next PR after this one is merged.

Another more general remark regarding the GPIO API: it is unfortunate that it is not possible to report errors on the GPIOs through the API (such as wire break, fault, etc.). The reading and analysis of error registers only provide output to the console. This is not very useful for normal operating conditions.

To be hones there are number of ICs (MAX22190, MAX14906, MAX14916 and other) which have advanced diagnostics and lack of way to report it in GPIO API really limit implementation and functionality. I was thinning to extend GPIO API to support diagnostics callbacks of something similar.

+#ifdef CONFIG_GPIO_DIAGNOSTIC
+       int (*diag_config_get)(const struct device *dev);
+       int (*diag_config_set)(const struct device *dev);
+       int (*diag_check)(const struct device *dev);
+#endif

@Piziwate
Copy link
Contributor

Piziwate commented Oct 22, 2024

Thanks @Piziwate

  • It seems to me that the latch pin is configured but never used. Typically, it is used when the IC operates in Daisy Chain mode.
  • It would be very beneficial to support Daisy Chain mode, as it is frequently used with this type of IC.

Agree it will be useful, I can add support for that in next PR after this one is merged.

Another more general remark regarding the GPIO API: it is unfortunate that it is not possible to report errors on the GPIOs through the API (such as wire break, fault, etc.). The reading and analysis of error registers only provide output to the console. This is not very useful for normal operating conditions.

To be hones there are number of ICs (MAX22190, MAX14906, MAX14916 and other) which have advanced diagnostics and lack of way to report it in GPIO API really limit implementation and functionality. I was thinning to extend GPIO API to support diagnostics callbacks of something similar.

+#ifdef CONFIG_GPIO_DIAGNOSTIC
+       int (*diag_config_get)(const struct device *dev);
+       int (*diag_config_set)(const struct device *dev);
+       int (*diag_check)(const struct device *dev);
+#endif

Indeed, that would be great! Ideally, the configuration of the filters and the wirebreak should also be possible via API in order to dynamically change the operating mode.
For your information, the Daisy Chain mode has been implemented for this driver #65982, it might inspire you.

@bogdanovs
Copy link
Contributor Author

Indeed, that would be great! Ideally, the configuration of the filters and the wirebreak should also be possible via API in order to dynamically change the operating mode.

This was just sample snippet, but yes all of those should be possible to configure. Maybe flags approach for overlapping functions and room for extension for custom flags and functions will be good. Need loo back on it think it thought again.

For your information, the Daisy Chain mode has been implemented for this driver #65982, it might inspire you.

Thanks!

MaureenHelm
MaureenHelm previously approved these changes Dec 9, 2024
Copy link
Contributor

Choose a reason for hiding this comment

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

Please move crc5 function to CRC subsystem (crc.h), we don't want more duplication of this code (see e.g.

static uint8_t max149x6_crc(uint8_t *data, bool encode)
or
static uint8_t i3c_cdns_crc5(uint8_t crc5, uint16_t word)
)
You may then also make CRC checking optional via a Kconfig like many other drivers do

Copy link
Contributor Author

@bogdanovs bogdanovs Dec 11, 2024

Choose a reason for hiding this comment

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

@kartben for MAX22190 and MAX149x6 CRC5 functions are taken from chip manufacturer noOS repo. From my understanding and testing calculation of CRC5 is different for those chips, following different flow.

for MAX22190
https://github.com/analogdevicesinc/no-OS/blob/cc73a3d70d056d143b783bd846489e2d2819ba7c/drivers/digital-io/max22190/max22190.c#L45

for MAX149x6
https://github.com/analogdevicesinc/no-OS/blob/cc73a3d70d056d143b783bd846489e2d2819ba7c/drivers/digital-io/max149x6/max149x6-base.c#L46

For i3c_cdns looks different too, but I am not familiar with that driver.

I can move MAX22190 CRC5 function to CRC subsystem if you think it is better there, even it is specific to MAX22190.

You may then also make CRC checking optional via a Kconfig like many other drivers do

If CRC is enabled depends on SPI Interface Modes - device tree option for this is max22190-mode. There are four modes available in for CRC and Daisychain. Mode is set from two pins which are pulled up or down M0 and M1, so it is hardware specific and belong to DT. From combination of those two pins CRC and Packet size are taken according to table.

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, let's process with the way it is right now. It is not clear to me if these various CRC5 variants cannot be factorized into a common on, but this shouldn't prevent this PR to land.

kartben
kartben previously approved these changes Dec 17, 2024
@kartben
Copy link
Contributor

kartben commented Dec 17, 2024

now has a merge conflict, unfortunately, please rebase @bogdanovs

Add max22190 gpio driver with input functionality, since device
support only input without output.

Implemented diagnostic functionality for all 8 channels
which include various check to over/under voltage and wire break.
Filtering configuration is done from devicetree on per channel
bases and is configured on chip start.

In case some fault condition occure FAULT pin drive LOW which
prop to FAULT registers to be read. Data is stored in data structure
for furter analizes and ERR message is printed in console.

Signed-off-by: Stoyan Bogdanov <[email protected]>
@bogdanovs bogdanovs dismissed stale reviews from kartben and MaureenHelm via 284b0a3 December 17, 2024 17:15
@bogdanovs
Copy link
Contributor Author

now has a merge conflict, unfortunately, please rebase @bogdanovs

@kartben rebased on latest main

@kartben kartben merged commit 92aeb78 into zephyrproject-rtos:main Dec 18, 2024
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: Devicetree Binding PR modifies or adds a Device Tree binding area: GPIO platform: ADI Analog Devices, Inc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants