-
Notifications
You must be signed in to change notification settings - Fork 855
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
AD2S1210 updates #2261
AD2S1210 updates #2261
Conversation
FYI, the checkpatch CI failure is due to the cherry-picked upstream commits. New patches look like they passed. dt_bindings_check CI failure is due to missing dt-doc-validate so seems like something not caused by these changes. |
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.
Looks fairly good to me. It needs some re-arrangement of the commits (some of them are also including some multiple changes - not sure if the maintainer will like it much) but I guess you can start the upstreaming process...
Some things that I would like to mention:
- I see the bindings CI job failed (need to see if there's anything we need to update in there). So, please locally make sure that the bindings are ok.
- Other things that I saw that you can potentially clean are: remove
of_match_ptr()
, apparently no need forspi_set_drvdata()
andspi_setup()
is also usually not needed (called already by the spi core)
ret = ad2s1210_set_mode(st, MOD_CONFIG); | ||
if (ret < 0) | ||
return ret; | ||
|
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.
unrelated change... This one and the above
ad2s1210_set_resolution_pin(st); | ||
ret = ad2s1210_set_resolution_gpios(st, udata); | ||
if (ret < 0) | ||
goto error_ret; |
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.
ditto
ad2s1210_initial(st); | ||
|
||
return 0; | ||
return devm_iio_device_register(&spi->dev, indio_dev); |
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'm not really sure if staging works like normal flow. But, if so, this patch would be one the first patch that touches the driver (fixes come first because of backporting - not sure if we really backport staging fixes). Also, a Fixes tag might be needed
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.
Ack. This is the first patch in the PR that isn't in 6.6 mainline already, so will be the first in the series submitted upstream.
Agreed. My first attempt was 50 patches which seemed like to much the other direction. So I will try to find some balance in between. |
c0d0601
to
369166a
Compare
Updates:
|
FYI for reviewers, per #2234 (comment) it looks like there will be a bit more work here before ready for review again. Although the patches here are unlikely to change much if you want to have a look anyway. |
369166a
to
3184d48
Compare
Updates:
|
3184d48
to
881c945
Compare
Updates:
|
3d80ed8
to
cbad00f
Compare
Updates:
|
36a2d94
to
71da83b
Compare
d9fde79
to
12578cc
Compare
Status update: There are just a few more patches pending upstream. Then I will add them here and remove the draft status. |
This reverts ADI merge commits 67d8979 "Merge tag 'xilinx-v2021.1' of https://github.com/Xilinx/linux-xlnx.git" and b6c8aa0 "Merge tag 'xilinx-v2020.1' into master-xilinx-v2020.1". This gets the driver back to the state it is in the mainline kernel. A different solution will be proposed to support optional gpios. Signed-off-by: David Lechner <[email protected]>
As stated in the device datasheet [1], bits a0 and a1 have to be set to 1 for the configuration mode. [1]: https://www.analog.com/media/en/technical-documentation/data-sheets/ad2s1210.pdf Fixes: b19e9ad ("staging:iio:resolver:ad2s1210 general driver cleanup") Cc: stable <[email protected]> Signed-off-by: Nuno Sá <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
With linux/acpi.h no longer implicitly including of.h, add an explicit include of of.h to fix the following error: drivers/staging/iio/resolver/ad2s1210.c:706:21: error: implicit declaration of function 'of_match_ptr' is invalid in C99 [-Werror,-Wimplicit-function-declaration] Acked-by: Jonathan Cameron <[email protected]> Reviewed-by: Jacob Keller <[email protected]> Reviewed-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Rob Herring <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
…vent attr The AD2S1210 has a programmable threshold for the degradation of signal (DOS) mismatch fault. This fault is triggered when the difference in voltage between the sine and cosine inputs exceeds the threshold. In other words, when the magnitude of sine and cosine inputs are equal, the AC component of the monitor signal is zero and when the magnitudes of the sine and cosine inputs are not equal, the AC component of the monitor signal is the difference between the sine and cosine inputs. So the fault occurs when the magnitude of the AC component of the monitor signal exceeds the DOS mismatch threshold voltage. This patch converts the custom device DOS mismatch threshold attribute to an event magnitude attribute on the monitor signal channel. The attribute now uses millivolts instead of the raw register value in accordance with the IIO ABI. Emitting the event will be implemented in a later patch. Signed-off-by: David Lechner <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jonathan Cameron <[email protected]>
The AD2S1210 has a programmable threshold for the degradation of signal (DOS) mismatch fault. This fault is triggered when the difference in amplitude between the sine and cosine inputs exceeds the threshold. The DOS reset min/max registers on the chip provide initial values for internal tracking of the min/max of the monitor signal after the fault register is cleared. This patch converts the custom device DOS reset min/max threshold attributes custom event attributes on the monitor signal channel. The attributes now use millivolts instead of the raw register value in accordance with the IIO ABI. Signed-off-by: David Lechner <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jonathan Cameron <[email protected]>
This adds a new optional field to struct iio_info to allow drivers to specify a label for the event. This is useful for cases where there are many events or the event attribute name is not descriptive enough or where an event doesn't have any other attributes. The implementation is based on the existing label support for channels. So either all events of a device have a label attribute or none do. Signed-off-by: David Lechner <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jonathan Cameron <[email protected]>
When reading the position and velocity on the AD2S1210, there is also a 3rd byte following the two data bytes that contains the fault flag bits. This patch adds support for reading this byte and generating events when faults occur. The faults are mapped to various channels and event type in order to have a unique event for each fault. Signed-off-by: David Lechner <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jonathan Cameron <[email protected]>
The ad2s1210 driver shoe-horns the register and fault support into IIO events. The mapping between the registers/faults and the events is not obvious. To save users from having to read the entire driver to figure out how to use it, add a summary of the register/fault support to the top of the file. Signed-off-by: David Lechner <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jonathan Cameron <[email protected]>
The ad2s1210 resolver driver has quite a few channels, mostly for internal signals for event support. This makes it difficult to know which channel is which. This patch adds a label attribute to the channels to make it easier to identify them. Signed-off-by: David Lechner <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jonathan Cameron <[email protected]>
Faults have been converted to events and we are now polling the fault register each time we read a sample, so we no longer need the fault attribute. This attribute was not suitable for promotion out of staging anyway since it was returning multiple values in a single attribute. The fault clearing feature should not be needed unless we need to support the fault output pins on the chip which is not currently supported. So we can add this feature back in if we need it later. Signed-off-by: David Lechner <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jonathan Cameron <[email protected]>
This refactors the sample line toggle in the ad2s1210 resolver driver to a separate function. The sample has some timing requirements, so this ensures that it is always done the same way, both in the existing call sites and any future usage. Previously, the sample line was kept on for the duration of the read, but this is not necessary. Data is latched in on the rising edge and after the specified delay the state of the sample line does not matter. Signed-off-by: David Lechner <[email protected]>
When a software reset is performed on the AD2S1210 to make the selected excitation frequency take effect, it always triggers faults on the input signals because the output signal is interrupted momentarily. So we need to clear the faults after the software reset to avoid triggering fault events the next time a sample is read. The datasheet specifies a time t[track] in Table 27 that specifies the settle time in milliseconds after a reset depending on the selected resolution. This is used in the driver to add an appropriate delay. Signed-off-by: David Lechner <[email protected]>
Use __attribute__((__cleanup__(func))) to build: - simple auto-release pointers using __free() - 'classes' with constructor and destructor semantics for scope-based resource management. - lock guards based on the above classes. Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lkml.kernel.org/r/20230612093537.614161713%40infradead.org
12578cc
to
49f6517
Compare
With the advent on scope-based resource management it comes really tedious to abide by the contraints of -Wdeclaration-after-statement. It will still be recommeneded to place declarations at the start of a scope where possible, but it will no longer be enforced. Suggested-by: Linus Torvalds <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lkml.kernel.org/r/CAHk-%3Dwi-RyoUhbChiVaJZoZXheAwnJ7OO%3DGxe85BkPAd93TwDA%40mail.gmail.com
We can simplify the code and get rid of most of the gotos by using guard(mutex) from cleanup.h. Signed-off-by: David Lechner <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jonathan Cameron <[email protected]>
This moves the ad2s1210 resolver driver out of staging. The driver has been fixed up and is ready to graduate. Signed-off-by: David Lechner <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jonathan Cameron <[email protected]>
The DRV_NAME macro is only used in one place in the ad2s1210 driver and is not really needed so let's remove it. Suggested-by: Jonathan Cameron <[email protected]> Signed-off-by: David Lechner <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jonathan Cameron <[email protected]>
To be consistent with the rest of iio, remove of_match_ptr(). It does not do anything useful here. Suggested-by: Jonathan Cameron <[email protected]> Signed-off-by: David Lechner <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jonathan Cameron <[email protected]>
It is possible to use the AD2S1210 with hardwired mode pins (A0 and A1). According to the devicetree bindings, in this case the adi,fixed-mode property will specify which of the 3 possible modes the mode pins are hardwired for and the gpio-modes property is not allowed. This adds support for the case where the mode pins are hardwired for config mode. In this configuration, the position and value must be read from the config register. The case of hardwired position or velocity mode is not supported as there would be no way to configure the device. Signed-off-by: David Lechner <[email protected]> Reviewed-by: Nuno Sa <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jonathan Cameron <[email protected]>
This adds support for the optional reset gpio to the ad2s1210 resolver driver. If the gpio is present in the device tree, it is toggled during driver probe before the reset of the device initialization. As per the devicetree bindings, it is expected for the gpio to configured as active low. Suggested-by: Michael Hennerich <[email protected]> Signed-off-by: David Lechner <[email protected]> Acked-by: Michael Hennerich <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jonathan Cameron <[email protected]>
This offers basic support for EVAL-AD2S1210SDZ on the ZedBoard. Co-developed-by: Apelete Seketeli <[email protected]> Signed-off-by: Apelete Seketeli <[email protected]> Signed-off-by: David Lechner <[email protected]>
49f6517
to
087e7af
Compare
I have rebased on the current master and added the remaining patches that were accepted upstream. To summarize:
Note: the CI failures (DCO and checkpatch) are caused by some of the cherry-picked upstream commits, so should be safe to ignore. Also did a quick smoke test to make sure this is still compiling and is reading data on our ZedBoard. |
How much are you using these new macros? Normally I'm not too keen in backporting things like this but bah, this should also not give me much pain when updating to a newer kernel... |
This is the only place so far. But the cleanup.h patches applied cleanly so back-porting it should be less trouble than reworking the last few patches here. |
This is working towards getting the AD2S1210 resolver driver out of staging.
Overview:
IIO_DMA_MINALIGN
(similar to some other drivers here)fclkin
attribute is removed and replaced with devicetree binding for getting clock rate.control
attribute is removed and replaced with debugfs register access.More detailed explanations of the changes can be found in the commit messages.
Ideas for additional changes:
resolution
seems like a better name thanbits
for the attribute that gets and sets the resolution, but this would be a breaking change to users of the staging driver.excitation_frequency
seems like a better name thanfexcit
for the attribute that gets and sets the excitation frequency, but this would be a breaking change to users of the staging driver.enable_hysteresis
attribute for getting and setting the hysteresis flag in the control register. Do users need this feature?phase_lock_range
attribute to get and set the phase lock range flag in the control register. Do users need this feature?Remaining tasks before submitting upstream:
Issue: #2234