-
Notifications
You must be signed in to change notification settings - Fork 8.2k
drivers: gpio: max22190: Add MAX22190 octal input with diagnostics #71141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
5ac5f2c to
823f4da
Compare
823f4da to
82aeb3f
Compare
d903a24 to
1aa75d3
Compare
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
1aa75d3 to
f589043
Compare
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
similar comment as above
f589043 to
b154371
Compare
MaureenHelm
left a comment
There was a problem hiding this 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
b154371 to
b5cbd91
Compare
21d8d38 to
36b0edc
Compare
f52e6fc to
06ff40a
Compare
|
Thank you for this contribution, which I find interesting. However, I have a few small remarks or suggestions :
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. |
|
Thanks @Piziwate
Agree it will be useful, I can add support for that in next PR after this one is merged.
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. |
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.
Thanks! |
06ff40a to
1fd68e5
Compare
1fd68e5 to
fe695a6
Compare
fe695a6 to
67b5c0b
Compare
drivers/gpio/gpio_max22190.c
Outdated
There was a problem hiding this comment.
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.
zephyr/drivers/gpio/gpio_max149x6.h
Line 30 in 3a69ed6
| static uint8_t max149x6_crc(uint8_t *data, bool encode) |
Line 601 in 3a69ed6
| 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
There was a problem hiding this comment.
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 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.
There was a problem hiding this comment.
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.
|
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]>
67b5c0b to
284b0a3
Compare
@kartben rebased on latest main |
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.